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!

Sum of Value of Two Text Boxes 1

Status
Not open for further replies.

jsaliers

Programmer
Jan 23, 2003
129
US
Sorry, this is probably a pretty lame question, but I can't figure it out. I have a form where techs report their hours. There are only two techs per job, so there are two fields where they record these values, Hours1 and Hours2. In order to do some reports, I would like to use the sum of these two values, and save them to the same table that Hours1 and Hours2 are saved in. I created a textbox in the form, named TotalHours. By setting the Data Source to =[Hours1]+[Hours2], I can get the value to display properly, but I cannot get the value to save to the field TotalHours in the table PD-JOB. Any ideas?

Thanks in advance for all your help!

Jon
 
In the AfterUpdate event of each of the Hour Fields, call the function UpdateTotalHours. Make sure that the control source property of TotalHours is set to the field in your table (i.e. it's a bound field).

Hours1
AfterUpdate... =UpdateTotalHours

Hours2
AfterUpdate... =UpdateTotalHours


Function UpdateTotalHours()

TotalHours = Hours1 + Hours2

End Sub

 
Thank you very much. It works perfectly. I have one additional question for you though. The database currently has many records already in the database. Is there any way to update these by simply viewing the record (i.e. scrolling through each record) instead of having to update at least one of the hours fields in the form?

Thank you again, and in advance!

Jon
 
Got it figured out. I called the function in the On Current Event, and scrolled through each record in the form, and it auto updated each of them.

Thanks again,

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top