record addition operator sum in table

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

Guest

I know the answer to this is PAINFULLY simple, not worthy of the minds here,
but I swear I haven't been able to find it anywhere else.

I have 2 fields in my form that record square footage and I need them to add
together to fill a third field. I have the addition operator in my form and
the correct number displays in the form, but I need the number to be recorded
in the table as well (for future use). How do I tell the form to enter the
total number in the correct field in my table? Thanks!
 
How about this:

If your table has columns Number_1, Number_2 And Sum, you can use this
code behind your form to update Sum whenever Number_1 or Number_2 are
updated:

Private Sub Number_1_AfterUpdate()
Let Me.Sum.Value = Me.Number_1.Value + Me.Number_2.Value
End Sub

Private Sub Number_2_AfterUpdate()
Let Me.Sum.Value = Me.Number_1.Value + Me.Number_2.Value
End Sub

That should do it.


Jon
 
I think we're close! However when I entered the (modified) version of the
code you suggested and attempted to enter data to test it I was returned an
error. It opened the Code Builder and told me:
"Compile Error
Method or data member not found"

the code I entered, changing the info to match my fields, was as follows:

Private Sub test_first_AfterUpdate()
Let Me.Sum.Value = Me.test_first.Value + Me.test_second.Value
End Sub

Private Sub test_second_AfterUpdate()
Let Me.Sum.Value = Me.test_first.Value + Me.test_second.Value
End Sub

....and when I got the error it highlighted the word "Sum" within "Let
Me.Sum.Value" in the "test_first" code

Help? Thanks!
 
Back
Top