boblarson
Smeghead
- Local time
- Today, 12:38
- Joined
- Jan 12, 2001
- Messages
- 32,059
1. You don't need the Else.
2. The code should work. It should, if the To date is before the From date hit the Cancel = True which should cancel the update and the Me.txtDateTo.Undo should undo the value in the control. So, not sure why it isn't working.
3. You COULD try this instead.
But it might not like the event trying to change the value in it.
2. The code should work. It should, if the To date is before the From date hit the Cancel = True which should cancel the update and the Me.txtDateTo.Undo should undo the value in the control. So, not sure why it isn't working.
3. You COULD try this instead.
Code:
Private Sub txtDateTo_BeforeUpdate(Cancel As Integer)
If Me.txtDateTo.Value < Me.txtDateFrom.Value Then
Cancel = True
Me.txtDateTo = Null
MsgBox "A date range must END later than it BEGINS!", vbCritical
End If
End Sub