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

real-time subform record change and totaling

Status
Not open for further replies.

alley

Programmer
Feb 8, 2000
51
US
With a main form and subforms, the user will change one or several numbers in either or both subforms, clicking a button to re-calculate totals and statistics, redoing the process until satisfied.<br><br>What is the code for cycling thru the records in subforms, inserting data and gathering totals?
 
Set the recordsource of the subform to something like<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Dim rst As Recordset, a As Integer, Subtotal As Double<br>&nbsp;&nbsp;&nbsp;&nbsp;Set rst = Me![your subform].Form.RecordsetClone<br>&nbsp;&nbsp;&nbsp;&nbsp;rst.MoveLast<br>&nbsp;&nbsp;&nbsp;&nbsp;rst.MoveFirst<br>&nbsp;&nbsp;&nbsp;&nbsp;For a = 1 To rst.RecordCount<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Subtotal = rst!ItemToAdd<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rst.MoveNext<br>&nbsp;&nbsp;&nbsp;&nbsp;Next<br>&nbsp;&nbsp;&nbsp;&nbsp;rst.Close <br><br>Then do each subform the same way.<br><br>Last, at the bottom of all of your code put the &quot;Subtotal&quot; variable back into a textbox on your form<br><br>Me!GrandTotal = Subtotal<br><br>OK <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Thank you DougP.&nbsp;&nbsp;Exactly what I needed..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top