>If I hit the escape key the textbox still has focus and
>when I attempt to move off it the valid fires. This is
>somewhat of a recursive issue.
To expand on Edward's answer:
When your form has a button whose cancel property is set to .T., this button is clicked when the user hits cancel anywhere on the form. But what is not obvious is that clicking this button with the mouse also sets the value of LASTKEY() to 27. So this covers all of your bases. In your valid event, use code like this:
IF !LASTKEY() = 27
IF This.Value > This.Parent.txtdpayment.value
MessageBox('Deposit date > Payment date',0)
RETURN 0
ENDIF
ENDIF
Erik Moore
Clientelligence