Bob,
Well, not really...
Given 2 bound fields (Num1 and Num2) on the same form, and an unbound calculated
control with
= Num1 + Num2
will yield the total, after each item is entered, or either item is changed...without a
Recalc or Refresh.
The same would hold true for an unbound Num1 and Num2, but with...
= Val(Num1) + Val(Num2)
as the calculation.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions
"Find a job that you love, and you'll never work a day in your life."
I am new to putting calculations on an Access form. I am trying to have
Access automatically calculate fields using the following formula:
=Sum([Question 1])+([Question 2])+([Question 3a])+([Question 3b])+([Question
3c])+([Question 3d])+([Question 3e])+([Question 3f])+([Question
3g])+([Question 3h])+([Question 3i])+([Question 3j]). For some reason, the
formulas willl not update or calculate in the field unless I save the page,
close and reopen it. What am I doing wrong? Thanks, Sue
OK, you have controls called [Question 1], [Question 2], etc. ... whenever one
of these values changes, the control containing the calculation formula needs to
be "told about it". You do this by invoking the "Recalc" method of the form
object in the AfterUpdate event of each control whose value is summed up in the
above formula.
You can achieve this in two different ways:
(1) In the OnAfterUpdate entry on the property page for each "Question..."
control, select "[Event Procedure]" from the drop-down list and click on the
button next to the entry with the "..." on it. You will instantly be "beamed up"
to the VBA code window where you can complete the code procedure by writing this
one line between the stub (i.e., the two lines Access generates automatically):
Private Sub Question_1_AfterUpdate()
' here is what YOU write:
Me.Recalc
' end of your added code
End Sub
To avoid doing this for each control, which can get tedious, there is also a
second method:
(2) Create your own "Recalc" subroutine as a function and set the OnAfterUpdate
entry of the property page to that function. To do this, switch to the code view
of your form's class module. Create one new function as follows:
Private Function UpdateMySums()
Me.Recalc
End Function
For each control's OnAfterUpdate entry in the property page, you can copy and
paste the same thing:
=UpdateMySums()
Start the entry with the "=" sign, i.e. there should be no space. This can be
easier when you have many controls which need to call the same function. Note
that you can only do this with functions, not subroutines (i.e. "Sub"s).