Access textbox BeforeUpdate cancel does not work
Posted on 2014-03-13
Have you ever had a canceled BeforeUpdate that did not work ? I have, and I don't understand any of it. Here is my code, on an unbound textbox in a straightforward Access form (Access 2007 SP3):
Private Sub txtGlobalLimitReviewDate_BeforeUpdate(Cancel As Integer)
If Me.txtGlobalLimitReviewDate > Now() + 365 Then
MsgBox "Review date may not be later than one year from now, please ammend", , "Correction required"
Cancel = True
When I set the date in that textbox to a date later than one year, I get my MsgBox message alright, but the date does NOT revert to the date I had before the change, it stays at what I just input ! I thought the idea of setting Cancel to True was exactly to cancel the current change and to reset the content as it was BEFORE the change the 'box OldVAlue) ? It seems the setting of the Cancel variable just doesn't do that. It prevents the excution of an AfterUpdate event processing which I have, but not the resetting to the previous value.
What can be the problem on such a simple thing ?
Thanks for help