Date text boxes

N

neeraj

I have 2 text boxes in my switchboard form, txtStrDte and txtEndDte, both
formatted to short date and input masked and the latter carrying a validation
rule of ">=[txtStrDte]" which if not met, pops a validation text message "End
Date has to be greater than or equal to Start Date". Everything works fine
except if one jumps directly to [txtEndDte] while providing values to these
boxes instead of going through providing value to [txtStrDte]. In this case,
if one were to try to go back to txtStrDte after providing value to
[txtEndDte], the validation message pops up and the cursor just doesn't move.
How can I resolve this?
 
A

Allen Browne

If this is a bound form, use the BeforeUpdate event of the *form* (not
controls) to perform the validation.

If unbound, you probably have a button that executes something based on the
dates, so use the Click event of this button.

(BTW, if you build a WHERE clause using the Between operator, Access will
still make sense of the values even if the first is after the second.)
 
K

Klatuu

I would suggest putting the following code in the Got Focus event of txtEndDte:

If IsNull(Me.txtStrDte) Then
MsgBox "Please Enter Start Date"
Me.txtStrDate.SetFocus
End If
 
Top