M
Maury Markowitz
I'm trying to prevent users from entering report dates in the future.
There's two primary dates, start (month end) and end (typically
yesterday or today). To prevent them from adding odd dates, I added a
BeforeUpdate handler like this...
Private Sub MonthDateField_beforeUpdate(Cancel As Integer)
If Me.MonthDateField > date Then
answer = MsgBox("You are entering a report date in the future.
Are you sure this is right?", vbYesNo)
If answer = vbNo Then
Cancel = True
Undo
Exit Sub
End If
End If
end sub
When I enter a bogus value, next year in this case, the msgbox popped
up as expected, but when I clicked "no" to reset the date back to what
it was, nothing changed. The cursor didn't move, the highlight didn't
change, nothing.
Any ideas? I can check the validity later in the code, but I prefer
immediate warnings.
Maury
There's two primary dates, start (month end) and end (typically
yesterday or today). To prevent them from adding odd dates, I added a
BeforeUpdate handler like this...
Private Sub MonthDateField_beforeUpdate(Cancel As Integer)
If Me.MonthDateField > date Then
answer = MsgBox("You are entering a report date in the future.
Are you sure this is right?", vbYesNo)
If answer = vbNo Then
Cancel = True
Undo
Exit Sub
End If
End If
end sub
When I enter a bogus value, next year in this case, the msgbox popped
up as expected, but when I clicked "no" to reset the date back to what
it was, nothing changed. The cursor didn't move, the highlight didn't
change, nothing.
Any ideas? I can check the validity later in the code, but I prefer
immediate warnings.
Maury