I have a User form that has a TextBox on, within that the user will input a date. I have an AfterUpdate routine on the TextBox to check the format of how the date has been input.
My problem is that if the date isnt in the correct format I want after the MsgBox to set focus on the the TextBox again but it doesnt like to do that and always goes onto the next TextBox.
How can I get around this?
Code:
Private Sub txtDateSource1_AfterUpdate()
If Me.txtDateSource1 <> Format(Me.txtDateSource1, "dd/mm/yy") Then
MsgBox "You must input the Order Date as dd/mm/yy before continuing.", vbExclamation, "Wrong Date"
txtDateSource1.SetFocus
Exit Sub
End If
End Sub