Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Fern Sanchez   on Nov 02 In MS Office Category.

  
Question Answered By: Dixie Jacobs   on Nov 02

I have tried putting the setfocus statement in the following control.
That does indeed reset the focus  back to the previous control, but
because the Afterupdate event has already been triggered I receive the
msgbox dialog again and then the focus moves back to the following
control.

However, your suggestion prompted me to look at the BeforeUpdate event,
and with the following amended code this works purfickly....

Private Sub txtCourseDate_BeforeUpdate(ByVal Cancel As
MSForms.ReturnBoolean)
If IsDate(txtCourseDate.Value) Then
txtCourseDate = Format(txtCourseDate, "dd/mm/yyyy")
Else
MsgBox ("Invalid date  format, please use 'dd/mm/yyyy'")
txtCourseDate.Value = ""
Cancel = True
End If
End Sub

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Userform Field Validation Or get search suggestion and latest updates.


Tagged: