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!

Form will not update table

Status
Not open for further replies.

cchahn

Technical User
Oct 8, 2003
23
I have a calculated field in a form that I want to update a field in a table. The field in the form computes the number of days between two dates. I want this result to appear in a table in a field called TotalDaysAway. The calculation works, but will not update the table when the record is saved.
 
You must do the calulation in code and drop the answer into the result textbox which can then be bound to the field in your table.

Use the Afterupdate event procedure for each of the date textboxes:

me!txtresult = me.txtdate1- me.txtdate2
 
I must be really dense today (it has been a long one), but I'm not getting it. The calculation is done in code and shows as the control source in the text box where I want the total days figure. By the Afterupdate procedure for the date textboxes, are you referring to the start date and end date text boxes?
 
A textbox can only have one source - it can be the underlying field or it can be a calculation - but not both.
If you want the result of a calculation to go into a textbox which is bound to a field you must do the calculation in VBA code (or you must post the result of the calculation to the field in code).

Since you do not know the order in which the user will enter the dates, you do the calculation in both cases, using the afterupdate event procedure.

To get there you disply the properties for the textbox and then click into the afterupdate event property. Then click the build button(...) which appears to the right.
Choose Code Builder when asked and this will drop you into the procedure. Add the one line of code as i indicated before (change the names those of your own textboxes).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top