Hi,
I'm having trouble setting the focus on a date text box in VBA.
I have performed error handling which will prevent the user enter an incorrect date format. I have tried several options from .setfocus etc but nothing seems to work, and trying to set the focus to another text box first then the txtdate textbox, could you please help me find a solution?
Many Thanks!
--------------------------------------------------------------------------
Private Sub txtdate_AfterUpdate()
If IsDate(txtdate) = False Then
MsgBox "Invalid Date format - dd-mm-yy", vbInformation, "Invalid Date Entered"
Cancel = True
txtdate.Text = ""
txtWO.SetFocus
txtdate.SetFocus
Exit Sub
End If
txtdate.Value = Format(txtdate.Value, "dd-mmm-yyyy")
End Sub
-------------------------------------------------------------------------
I'm having trouble setting the focus on a date text box in VBA.
I have performed error handling which will prevent the user enter an incorrect date format. I have tried several options from .setfocus etc but nothing seems to work, and trying to set the focus to another text box first then the txtdate textbox, could you please help me find a solution?
Many Thanks!
--------------------------------------------------------------------------
Private Sub txtdate_AfterUpdate()
If IsDate(txtdate) = False Then
MsgBox "Invalid Date format - dd-mm-yy", vbInformation, "Invalid Date Entered"
Cancel = True
txtdate.Text = ""
txtWO.SetFocus
txtdate.SetFocus
Exit Sub
End If
txtdate.Value = Format(txtdate.Value, "dd-mmm-yyyy")
End Sub
-------------------------------------------------------------------------