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

Updating table with calculated field 2

Status
Not open for further replies.

OMoore

Technical User
Oct 23, 2003
154
EU
Is it possible to add the value from a calculated field on a form to a table? (although I do know it's not best practice to store calculated fileds in a table!!)
Owen
 
You're quite right, it's probably going to create some headaches later on.

Create a new textbox on the form and bind it to the field you want to save it to, and then in a relevant event:

[tt]Me!txtNewBox.Value = Me!txtCalculatedBox.Value[/tt]

Not sure which event though, on current fires when you enter the record, perhaps the forms before update? Try it out.

Roy-Vidar
 
I've tried it but can't get it to work. I've put the following into the on close event.

Me!Text2.Value = Me!Text4.Value

where text2 is the field bound to the table and text4 is the calculated field.

I've also tried it on the after update event for the calculated field.

Help!!!
 
The after update of a calculated control does not fire at all (to my knowledge). The close event of the form, hmmm, don't know, but what happens with changes in each record - or is this not dependent on changes in each record?

If you need to try it on some control events, try the after update on (all) the control(s) providing the values for the calculated control, else I continue to recommend trying the before update event of the form as a possible alternative, because that will fire whenever a record is saved ( - so on any change in any of the values in the forms controls, that are saved to the record, this event will fire)

To test whether it works at all, try creating a button first, and see if the code works, then play with the events.

Roy-Vidar
 
Your correct! The forms before update field works perfectly.
Thanks very much.
Owen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top