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!

Calculate All

Status
Not open for further replies.

cydud3

IS-IT--Management
Dec 21, 2004
57
0
0
KE
Hi. I have a form with several textboxes containing numbers. I then have another "result" textbox which contains the sum (or other arithmetical functions) of the previous textboxes. I also have a "calculate" button which obviously puts the resulting calculation to the "result" textbox.

I want to create a "Calculate All" button. How do I make it so that when I press the button, it calls the calculate function, then skips over to the next record, calls the calculate function again, and so on...until the end of the recordset?

2B||!2B
 
Why not simply an UPDATE query ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I was hoping I can do it as a function because there is already a set process to come up with the source numbers (they are also calculated, not entered manually) and often times the values to be calculated are stored only as value of the form control, not on table.

If it comes down to it, I might start messing around with update queries.

2B||!2B
 
I somewhat have an idea how to do it...It looks like the following.
Code:
Private Sub btnCalcAll_Click()
    Dim Counter As Integer
    
    Counter = 0
    
    DoCmd.GoToRecord , , acFirst
    Do While Counter < 70
        CalcAmount_Click
        DoCmd.GoToRecord , , acNext
        Counter = Counter + 1
    Loop
End Sub

I want to replace the counter with something more dynamic. For example, it should automatically detect that it is the last record in the form. I do not know how else to end the loop. Any ideas?

2B||!2B
 
Something like this ?
Do While Counter < Me.RecordsetClone.RecordCount

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks. That seems to have worked. I'm just not that familiar with VB syntax.

2B||!2B
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top