Dates

D

Dennis

How can I have access verify that I did not enter dates
incorrectly. I need the date to be the 26th of the current
month and the current year.

Thanks,

Dennis
 
A

Allen Browne

This example shows how to use the AfterUpdate event of the text box (named
txtDate) to get the user's confirmation to change the date if necessary:

Private Sub txtDate_AfterUpdate
Dim dt As Date
Dim strMsg As String

If Not IsNull(Me.txtDate) Then
If (Day(Me.txtDate) <> 26) Or (Year(Me.txtDate) <> Year(Date)) Then
dt = DateSerial(Year(Date), Month(Me.txtDate), 26)
strMsg = "Should be " & dt & "?"
If MsgBox(strMsg, vbYesNo) = vbYes Then
Me.txtDate = dt
End If
End If
End If
End Sub
 
D

Dennis

Thanks Allen!

Dennis

-----Original Message-----
This example shows how to use the AfterUpdate event of the text box (named
txtDate) to get the user's confirmation to change the date if necessary:

Private Sub txtDate_AfterUpdate
Dim dt As Date
Dim strMsg As String

If Not IsNull(Me.txtDate) Then
If (Day(Me.txtDate) <> 26) Or (Year(Me.txtDate)
 
Top