Date Check (1 Viewer)

Kundan

Registered User
Joined
Mar 23, 2019
Messages
78
In the attached DB I am entering dates in the pop up form. If date is less than today it asks whether date is correct. If I say NO I want cursor to remain in the DT field. For this I have written a code Me.DT.SetFocus. But it is not happening. Please guide me.
 

Attachments

bob fitz

AWF VIP
Joined
May 23, 2011
Messages
3,598
Your validation code needs to be in the Before Update event of the form or the control that you are editing. Try the following code in the BeforeUpdate event of the control called DT:

Code:
If (Me.DT < Date Or Me.DT >= (Date + 30)) Then
    If MsgBox("Are you sure DATE is correct?", vbDefaultButton2 + vbYesNo + vbQuestion) = vbNo Then
    Cancel = True
    End If
End If
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom