Lost Focus

socko139

Registered User.
Local time
Today, 08:53
Joined
Feb 22, 2001
Messages
25
Hey guys..I've almost finished writing my code, but I need to know how to get it to work when I leave my text field: I wrote the following code:

Private Sub TextBox4_LostFocus()
If Not IsDate(TextBox4.Text) Then
MsgBox "Please input a valid time."
Else
TextBox4 = Format(TextBox4.Text, "hh:mm:ss AMPM")
End If
End Sub

but when I tab out of textBox4 my code does not trigger. (It does work though if I apply it to a coomand button on click) Anyone see any problems with it to get it to run upon exiting a textbox field? Thanks!
 
Your code seems to work fine for me. Which part isn't working, the invalid time message, the formatting of the text box entry or both?

Check the "On Lost Focus" cell in the text box's property sheet, and make sure that it is linked to the event procedure you have in your code.
 

Users who are viewing this thread

Back
Top Bottom