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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help me with this DataGrid dilemma! 1

Status
Not open for further replies.

shem

Technical User
Oct 30, 2001
5
0
0
GB
On a form I am creating a sales record that has multiple lines (using a tempRS based on an ACCESS database). I have 5 txtBoxes (Product, Quantity, UnitPrice, LineTotal, JobTotal) that populate (via cmdButton) a DataGrid (Adodc control). The "JobTotal" txtBox and column contain a running tally of the sales record.
After a row is on the DataGrid I would like to be able to edit one of the columns (cells - i.e. Quantity or UnitPrice) and have it re-calculate the LineTotal and JobTotal columns and JobTotal txtBox. I'm fairly new to VB and would greatly appreciate some help from someone OR tell me where to find help with DataGrids. THANKS!!
 
It is usually not a good idea to have totals of any sort on the same table as the data entries.
If you want to see totals on the form, use an unbound text box that has an expression that totals the column using a snapshot recordset.
That way, when you alter any one entry, refresh the totals control and it will reflect the new total.
Running totals are usually done when you print out a report.
If you wanted to recalculate all the running totals on a table you would have to use a recordset dynaset and go from the first to the last record and recalculate every row like[ Set up Recordset : RecordSet.MoveFirst: Do until Recordset.EOF : RunningTotal=WhateverYourCalculationIs : RecordSet.MoveNext : Loop ] See the various examples.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top