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
Printable View
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
do you mean like this
Code:'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
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.