Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sum

Status
Not open for further replies.

genoah

Programmer
Nov 1, 2001
24
0
0
US
How can get the sum of a found set of records when a user exits a grid?
 
Is it a stringgrid or a dbgrid? If it's a stringgrid you could just cycle through and add them up, if a dbgrid you could go through the query records and add them up or you could request a sum from the database.

If you're trying to sum up only records they selected I think that multiple select in dbgrids gives you a list of bookmarks you could run through.

Hope that helps!
TealWren
 
Its a dbgrid and I select a list of recoreds for a customer, like a order of 10 different products. When the user tabs or moves to the next line, I would like it to update the amount due. s-)
 
The difficulty I've found with this kind of thing is not doing the calculation, but triggering it. OnColExit catches tabbing across columns and to get the move to the next line you can use OnDataChange of the DBGrid's DataSource. However if you want to change anything on the relevant table(s) then you may get a loop with OnDataChange calling itself!
 
Can you give me a example of code that I code use in a dbgrid for a oncolexit event? I am having a tuff time with this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top