PDA

Click to See Complete Forum and Search --> : Add numbers dynamically


Eby72
Jul 27th, 2001, 12:37 PM
Can somebody help me...on how to do the following? I have 4 number fields in a form.....I want to add those to the total field each time I tab from one field to another....(ie Add dynamically)

Thanks

Bjwbell
Jul 27th, 2001, 03:02 PM
do you mean like this


'add four textboxes and one label


Private Sub Text1_Validate(Cancel As Boolean)
Label1.Caption = Text1.Text

End Sub



Private Sub Text2_Validate(Cancel As Boolean)
Label1.Caption = Int(Label1.Caption) + Text2.Text
End Sub



Private Sub Text3_Validate(Cancel As Boolean)
Label1.Caption = Int(Label1.Caption) + Text3.Text

End Sub



Private Sub Text4_Validate(Cancel As Boolean)
Label1.Caption = Int(Label1.Caption) + Text4.Text
End Sub

Guv
Jul 27th, 2001, 03:09 PM
Write code for the LostFocus Event which will do conversions and addition to the total.

You will probably need a Boolean variable which gets set by the Change event for the Textbox and reset by the LostFocus event. If you are not careful, you will add the same amount to the total twice.