Can anyone please help me?
Users enter a date on a form control [txtas400date] - a date which is usually within the previous 7 days of the current date. I want to prompt the user to check the date entered if it is older than the 7 days but allow entry if the user confirms. I also want to prevent a date later than the current date. I entered the following on the "Before update" event of the control but receive a Run-time error message 2115. Where am I going wrong?
Private Sub txtas400date_BeforeUpdate(Cancel As Integer)
If DateDiff("d", [txtas400date], Date) >= 7 Or DateDiff("d", Date, [txtas400date]) >= 1 Then
If MsgBox("Please check date, Correct?", vbYesNo) = vbYes Then
' If User chooses yes, then force a save by setting Me.Dirty = False
Me.Dirty = False
Else
'set text box to null (="")
Me!txtas400date = Null
Cancel = True
End If
End If
End Sub
Users enter a date on a form control [txtas400date] - a date which is usually within the previous 7 days of the current date. I want to prompt the user to check the date entered if it is older than the 7 days but allow entry if the user confirms. I also want to prevent a date later than the current date. I entered the following on the "Before update" event of the control but receive a Run-time error message 2115. Where am I going wrong?
Private Sub txtas400date_BeforeUpdate(Cancel As Integer)
If DateDiff("d", [txtas400date], Date) >= 7 Or DateDiff("d", Date, [txtas400date]) >= 1 Then
If MsgBox("Please check date, Correct?", vbYesNo) = vbYes Then
' If User chooses yes, then force a save by setting Me.Dirty = False
Me.Dirty = False
Else
'set text box to null (="")
Me!txtas400date = Null
Cancel = True
End If
End If
End Sub