Updating fields in a subform record

dsoderstrom
dsoderstrom used Ask the Experts™
on
I have a subform in Access bound to a table.  The subform has several columns that are enabled and several that are not enabled.  All of the columns are bound to fields in the table.  When exiting a record in the subform I want to update the columns that are not enabled based upon data entered in the enabled columns.  What event should I do this on?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
That will happen automatically.

Author

Commented:
The unenabled columns would update automatically if the Control Source for them was a formula but it's not.  They are bound to fields in the table.  Their value will be determined by what gets entered in several of the enabled columns.
I can put code behind the After Update event of the enabled columns involved in the calculations but I have to put the same code behind each one of them .  I thought it would be easier to do the calculations for all unenabled fields all at once when exiting the record after all enabled fields have been entered.  But, if running the calculations on the After Update event of each field is the only way to do it then I can do it that way.
Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
I see. You should put your update code in the BeforeUpdate event of the form.
Distinguished Expert 2017
Commented:
Chances are excellent that you should not be storing the calculated values anyway.  They should be calculated in the query.  In that case, Access will automagically update the calculated columns when you change the data.  That way you'll see the values immediately.  Your present method and Gus' suggestion won't show the values until you leave the record.  Check out Normalization and pay attention to the first three normal forms so get some understanding of why storing calculated values is a violation.

Author

Commented:
Thanks guys for straightening me out.  After looking at this a little more I realized that i really do not need to store the calculated values.  I created my own problem by including them in the table and making them bound fields in the form.  I appreciate the help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial