Jeff ---
Here is the text of the FAW I wrote (sorry, wasn't KB).
---------------------------------------------------------------------
A common problem is that Valid always fires, regardless of the actual status of the add or edit. Logically, if an edit is being cancelled, you do not want to enforce validation.
There is a way to do it. If involves using some old (but still supported) Fox commands:
LOCAL nCancelTop,nCancelHeight,nCancelLeft,nCancelWidth
nCancelTop=THISFORM.cmdCancel.Top
nCancelBottom=nCancelTop+THISFORM.cmdCancel.Height
nCancelLeft=THISFORM.cmdCancel.Left
nCancelRight=nCancelLeft+THISFORM.cmdCancel.Width
IF BETWEEN(MROW("MyForm",3),nCancelTop,nCancelBottom) AND ;
BETWEEN(MCOL("MyForm",3),nCancelLeft,nCancelRight) AND ;
MDOWN()
RETURN .T.
ENDIF
What this code does is look for the "cancel" button and test the mouses position and "button down" status to see if the cancel button is being clicked. If it is, Valid returns True and the control can be left without validation. To use this code, substitute your form's name for MyForm and your cancel buttons name for THISFORM.cmdCancel.
You could actually block several controls from validation by just reiterating this code for every control that you want to skip validation on.
---------------------------
HTH
John
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05