Thanks for reply combo, but I still have a fundamental problem. Here's the full story behind it, hope someone can help me out.
I'm having some problems validating a textbox field on a userform within EXCEL97. In addition to my textbox I also have an exit button and date and time picker control. My problems are these.
1) I have the following validation code on the exit event of my text box. The idea being that you should not be able to leave this box unless there is a valid number entered or its blank.
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Cancel = False
If TextBox1.Value = "" Then
Exit Sub
Else
' validation code goes here which
' sets itsvalid to false if its invalid
' and then ...
If itsvalid = false Then
MsgBox ("Invalid number, please re-enter"

Cancel = True
UserForm2.TextBox1.SetFocus
End If
End Sub
This works fine except in the following scenario:- I'm in the textbox, enter an invalid number then click on the down arrow of my date picker control. I get the warning message about the number being invalid but the focus does not seem to be getting set back to the textbox field as the calendar drop down event of my date picker still occurs. Anyone come across this problem before? How do I prevent this happening.
2) My other problem is this. If I'm on the texbox field enter an invalid number then click on my exit button to quit out the form the validation code still fires even though I've set the getfocusonclick to false on my exit button. How do I set it up so that the texbox validation code does NOT fire when I click my exit button?
I suspect I'll have to use API/hooks to do what I want but I'm not experienced in using those techniques so any pointers would be welcome.