By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,285 Members | 1,636 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,285 IT Pros & Developers. It's quick & easy.

How to update field in a table

P: 1
I created a table contains value1, value2 and average. I created a form to enter data and calculate average as value1+value2. In form, it shows actual result but data is not updated in table. Why?
Aug 3 '07 #1
Share this Question
Share on Google+
2 Replies


P: 27
I created a table contains value1, value2 and average. I created a form to enter data and calculate average as value1+value2. In form, it shows actual result but data is not updated in table. Why?
Try it like this:

1: Set up your form with Value1, Value2 and Avg, each one being bound to the table in question.
2: Add the following macro to the On Change event of Value1 and Value2 boxes:

SetValue
item: Avg
Expression: [Forms]![table]![Value1]+[Forms]![tbl]![Value2] / 2

That should work, and save the value in the table too. Alteratively you could add the macro to the On Click event of a "Calculate!" button you add to the form.
Aug 3 '07 #2

Rabbit
Expert Mod 10K+
P: 12,392
I created a table contains value1, value2 and average. I created a form to enter data and calculate average as value1+value2. In form, it shows actual result but data is not updated in table. Why?
It's not working because the control source isn't set to the field in the table.

Henhoue showed you how to do it using macros. You can also do it using VBA code.

As for storing the average, there's no need, it can easily be calculated when needed.

And your formula for average is wrong, it's Sum(X) / n.
Aug 3 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.