Adding two textbox Values

G

Guest

Hi,
I have a form in which I m trying to add the value of two bound textboxes
to be displayed on a third textbox, the sum on the third textbox is not
stored on the table.
I've tried to add this code:

Private Sub TxtQuantity_AfterUpdate()
Me.TxtTotal= Me.TxtQuantity + Me.TxtLabor
End Sub


Private Sub TxtLabor_AfterUpdate()
Me.TxtTotal = Me.TxtQuantity + Me.Quantity
End Sub



However, when I reopen the form and I used the record navigation button, the
value of the textbox Total for the first record is desplayed for all the
other records.

For example, the table has Quantity=5; Labor=9 for record 1 and the form
shows 45 in the texbox which is correct, however if record 2 has Quantity=6;
labor=3 the Total textbox keeps showing 45, and the same for all the other
records.

I've tried to put the above code in the On Dirty event and there is no
different.

How can I make the the TotalTxtbox to show the corrct value for each record ??
I appreciate your help!
 
J

J_Goddard via AccessMonster.com

Hi -

Put the code in the on current event of the form as well - that will cause me.
TxtTotal to be updated each time you move to a new record.

John
 
G

Guest

Why not just use a calculated field like this --
Total: [Quantity] * [Labor]

Or in the query SQL this ---
SELECT [Quantity], [Labor], ([Quantity] * [Labor]) AS Total, ....
 

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

Top