Good day. Either I'm not interpreting the BeforeUpdate event docs correctly or it doesn't work as described. Here's a line from the docs:
Sorry, I don't have enough posts to be able to post links but it is the Form.BeforeUpdate article in the standard Microsoft documentation.
The following code will output the debug statement and cancel the update when txtStartDate is before today but it does not revert to the OldValue as it states in the documentation. Doing an undo on the control works but I'm wondering why it isn't reverting back with the cancel as advertised.
Thank you,
Tom
If you cancel an update, the value of the OldValue property replaces the existing value in the control.
Sorry, I don't have enough posts to be able to post links but it is the Form.BeforeUpdate article in the standard Microsoft documentation.
The following code will output the debug statement and cancel the update when txtStartDate is before today but it does not revert to the OldValue as it states in the documentation. Doing an undo on the control works but I'm wondering why it isn't reverting back with the cancel as advertised.
Code:
Private Sub txtStartDate_BeforeUpdate(Cancel As Integer)
If Me.txtStartDate < Date Then
Debug.Print "Start date earlier than today"
Cancel = True
End If
End Sub
Thank you,
Tom