Trouble closing a form

J.Windebank

Registered User.
Local time
Today, 17:54
Joined
Apr 2, 2003
Messages
37
Hi everyone,

I have a form that has two text boxes, in the first you enter a 4 digit number, and on exiting it (LostFocus) is automatically adds the 4 digit number, minus 1, into the second box, and moves focus to the third contrrol on the page.

The way I am doing this is by having:

txtBox1:
Code:
Private Sub txtBox1_LostFocus()

     intPR = txtBox1.Text - 1

End Sub

And for txtBox2:
Code:
Private Sub txtBox2_Enter()

     txtBox2.Text = intPR
     txtBox3.SetFocus
     
End Sub

Now this all works fine, except I have a command button to close the form, and if you try to close it without having any text in txtBox1, it produces the following error:

Code:
Run Time Error '13':

Type Mismatch

Anyone know a simple way around this please?

Thanks,

Jordan
 
Why not get rid of all the code and ad the following to the After Update event of the first textbox:

intPR = txtBox1 - 1

HTH
 
Thank you, works a treat, never even thought of AfterUpdate to be honest. Still have a lot to learn :)
 
Glad I could be of help...so far I was 0 for 4 today...

Must need more coffee.
 

Users who are viewing this thread

Back
Top Bottom