Automatically recalculate a sum field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have fields for mon, tue, wed, etc. I have a text box at the end that
calculates the running total of these fields. How do I get this field to
update it's total if someone changes the total say on wednesday without
having to press the F9 key?

Thanks in advance!
 
Hi mgkaam,

You can create the following function in the form's code module:

Option Compare Database
Option Explicit

Function RefreshTotal()
On Error GoTo ProcError

Me.txtNameOfControl.Requery

ExitProc:
Exit Function
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure RefreshTotal..."
Resume ExitProc
End Function


To call this function, place the following in the After Update event
procedure, shown in the Properties tab for each of the text boxes Monday,
Tuesday, Wednesday, etc.:

=RefreshTotal()


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
Thanks for the answer! Is there a easier way of just having my unbound total
field just change it's total when say thursday's amount is entered after
having mon, tues weds total in there, basically a current running total
field? Just trying to keep this simple.

Thanks again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top