Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #11  
Old 10-02-2016, 10:50 AM
tcsh tcsh is offline
Member
 
Join Date: Sep 2016
Posts: 37
Default

Quote:
Originally Posted by Jasser View Post
Use the same code that I posted before. On the other hand, you can use a TLabel or TEdit to show the sum. I prefer to use a TLabe.
Thanks for the reply, I've modified the needed things in your code as to what I'm using, please let me know if you spot something wrong.

Code:
procedure TForm2.comenziDataSetAfterPost(DataSet: TSimpleDataSet);
var
          xSum : Integer;
          pBM  : TBookmark;
begin
          xSum := 0;

          pBM := comenziDataSet.GetBookmark;

          comenziDataSet.DisableControls;
          comenziDataSet.First;

          while NOT comenziDataSet.Eof do begin
                xSum := xSum + comenziDataSet['Thefield'];

                comenziDataSet.Next;
          end;

          comenziDataSet.GotoBookmark(pBM);
          comenziDataSet.EnableControls;

          TLabel1.Caption := IntToStr(xSum);
Assuming I modified it correctly the only thing I'm not understanding is TheField part, that's shown in red.

Is that where I type in the column name that holds all the things needed to be summed up? If so, my db name is tipotask, table name is comenzi and column name in question is pret, how would I write that there?

Also, where do I paste this code? on my main form, right? (that's where the label would be and the dbgrid)

Thanks again!
Reply With Quote
  #12  
Old 10-02-2016, 02:42 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default

In your case the field (In RED) should be "pret".

Put the code in the form that has the table/component "comenzi".
__________________
Regards,
Abdulaziz Jasser
Reply With Quote
  #13  
Old 10-02-2016, 04:07 PM
tcsh tcsh is offline
Member
 
Join Date: Sep 2016
Posts: 37
Default

Quote:
Originally Posted by Jasser View Post
In your case the field (In RED) should be "pret".

Put the code in the form that has the table/component "comenzi".
Thanks for the help
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 10:53 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.