alert for incorrect date entry (1 Viewer)

3699wat

Registered User.
Local time
Today, 16:39
Joined
Oct 28, 2002
Messages
83
I’m trying to set a code to an event procedure of a textbox (Date/Time) that will alert the user when the date entered is greater than today and return the focus to the textbox for correction. Here’s what I used. It pops up the message box, but does not set the focus back to the textbox. Here’s the code

Private Sub DateOnset_LostFocus()
If Me.DateOnset > Date Then MsgBox ("mmmm"), vbOKOnly
Me.DateOnset.SetFocus

End Sub
 
R

Rich

Guest
Private Sub txtDate_BeforeUpdate(Cancel As Integer)
Dim Msg, Style, Title, Response, MyString
If DatePart("yyyy", Me.txtDate) <> DatePart("yyyy", Date) Then
Beep

Msg = "The date you have entered is not the current year is this correct ?"
Style = vbYesNo + vbExclamation + vbDefaultButton1
Title = "Date verification"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
Exit Sub
Else
Cancel = True
Me.Undo
End If
End If
End Sub
 

3699wat

Registered User.
Local time
Today, 16:39
Joined
Oct 28, 2002
Messages
83
Rich

just what I needed

thanks
 

Users who are viewing this thread

Top Bottom