I would recommend you make sure the buttons cancel property is set to .T. Then surround the Valid code with "If lastkey() <> 27......endif. Clicking on a button with the Cancel prop set to .t., sets lastkey = 27.
Pf
>I have several textboxes that I am using within a form that is being used for data entry.
>
>I am using the the textboxt Valid Event to run a query (if the textbox is not empty) based on the value entered in that textbox. The code is basically as follows:
>
> IF NOT EMPTY( This.value)
> rc_custno = ALLTRIM( This.Value)
> ThisForm.m_query()
> ELSE
> WAIT WINDOW "Customer # must be entered"
> ENDIF
>
>However, if I don't enter a value and decide to exit the form by using a command button set up for thisform.release(), it still runs teh valid event (ofcourse) and gives me the WAIT WINDOW message.
>
>Ideally I would want this code to fire only when I press TAB or ENTER, and I know that I should be using the KEYPRESS event or sort of it, but I can't get the syntax correct. help.
>
>Thanks,
>
>Alex
(On an infant's shirt): Already smarter than Bush