Adding values

  • Thread starter Thread starter Shirley
  • Start date Start date
S

Shirley

I need to add the values entered into two different fields
on a form to display in a totals field shown elsewhere -
it needs to update as the user enters the information in
the referenced fields - anyone know how to do this?

User friendly terms please ;o)
 
Shirley

First, since I'll assume that a value can be entered in either, both or
neither of the "two different fields", you'll need a way to do the
calculation/recalculation after a change to either field, right?

One approach would be to add a new text control to the form, but not connect
it to any existing field from the underlying table or query -- this is
considered "unbound".

You need to open the Properties window for this new control, and select the
Control Source property. In this field, add an expression something like
(your syntax may vary):

= [YourFirstControlName] + [YourSecondControlName]

Then, open the property window for each of your two different fields (i.e.,
controls). In each, in the AfterUpdate event, add an expression/code that
will force the form to recalculate -- it looks something like:

Me.Recalc
 
I will take your question to mean that you want to display
only, not store the values. Create two text boxes on the
form, named txtOne and txtTwo. Right click each, and
select Properties. Click the Format tab, click in the
Format line, click the down arrow, and select General
Number. Create a third text box. Select Properties as
above. Click the Data tab, and in Control Source enter
(without the quotes) "= txtOne] + [txtTwo]".
Another approach is to go to the form's underlying table.
In design view, create fields One and Two. Set the Data
Type to Number (Long Integer in Field Size is OK). Back
to the form, set the Control Source (as above) of txtOne
to One, of txtTwo to Two (use the down arrow to select the
field). Leave the third text box as it is.
There are other possible answers as well, such as
calculate queries. You might need to provide some more
details of what you need to do. Remember that if this is
stored data you will probably want to store the individual
numbers that are added together, not the sum.
 
Back
Top