Add up fields within a Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form (frmTesterInfo). Within the form, I have 4 text boxes. The
text boxes are Total Executed, P, RB and FB. I want the text box Total
Executed to add up the data that is keyed into P, RB and FB. I tried to
create a Macro (SetValue) and I could not get it to work. What is the
easiest way to get these fields to add up. Plus, I need to be able to
store the Data in the table, That is a MUST. How can I get this to work?
 
If you MUST store a calculated value in a table, you MUST create a procedure
that ensures your data's integrity. If any of the components (or the stored
total) is modified, either via forms or directly in the table or via code,
YOU are responsible for ensuring that the calculation/re-calculation takes
place, and all four values are still in synch.

Or you could take a somewhat easier approach and use a query to derive the
calculated value whenever you need it, and only store the raw values.

To get the form (not the table) to display the calculated value, you could
use an unbound textbox, and in the Control Source property, put something
like:

= [P] + [RB] + [FB]

You may need to re-calculate the form after any change to any of those three
components.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
I would create an unbound text box whose control source is the addition of
the amounts in the four text boxes. Why must the data be stored in a table
(I can tell you right now, there are very few (if any) valid reasons why
this should be done)? You could run a mcro or some VBA script that updates
that field in the table with that of the unbound text box, but again, a bad
idea. What if the program crashes, for example, the field doesn't get
update?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top