Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB-Aware

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 12-18-2001, 01:04 PM
FreakAzoid FreakAzoid is offline
Senior Member
 
Join Date: Jan 2001
Posts: 614
Default DBGrid and Running Balance column...

I have a table with an amount field.
I have in another table the beggining balance for that column.
what i need is a column that contains the balance in a running fashion.

beginning balance: 100.00

amount balance
5.00 105.00
7.25 112.25
and so on...
Standard delphi DBGrid no freeware/shareware stuff...

thanks
Reply With Quote
  #2  
Old 12-18-2001, 01:36 PM
MrBaseball34 MrBaseball34 is offline
Senior Member
 
Join Date: Jan 2001
Posts: 7,260
Default RE: DBGrid and Running Balance column...

Ok...
Add a calculated field to your database using the field editor. Call it Balance.

Then in your Table's OnCalcFields handler, add this code:

Table1Balance.Text := FloatToStr(Table2BegBalance.Value + Table1Amount.Value);
Reply With Quote
  #3  
Old 12-18-2001, 01:44 PM
FreakAzoid FreakAzoid is offline
Senior Member
 
Join Date: Jan 2001
Posts: 614
Default RE: DBGrid and Running Balance column...

i have tried that just yet but had tried something similar but the data i got was...

amount balance
5.00 105.00
7.25 107.25(112.25)
Reply With Quote
  #4  
Old 12-18-2001, 01:59 PM
MrBaseball34 MrBaseball34 is offline
Senior Member
 
Join Date: Jan 2001
Posts: 7,260
Default RE: DBGrid and Running Balance column...

That's going to be a little more difficult to do, then
because you are going to have to calcuate the total on
your own and add it to the Amount...
try this:

Have a form local var called CalcBalance.

then add these two lines in your OnCalcFields handler.

Table1Balance.Text := FloatToStr(CalcBalance + Table1Amount.Value);
CalcBalance := Table1Balance.Text
Reply With Quote
  #5  
Old 12-18-2001, 02:03 PM
FreakAzoid FreakAzoid is offline
Senior Member
 
Join Date: Jan 2001
Posts: 614
Default RE: DBGrid and Running Balance column...

I think that will do it. Thanks alot...
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 Off

Forum Jump


All times are GMT. The time now is 06:56 PM.


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