>Hi. VFP6 user here. I am having trouble placing the user back in the current field when my data validation fails. Fox doesn't like SetFocus in the valid, and it doesn't seem to work for me in the LostFocus.
>
>For Example (in LostFocus)
>IF ! "Dr" $ This.Value
> =messagebox('This list should be Doctors only.',16,'Go Back')
> This.SetFocus
>ENDIF
>
>...doesn't work
>
>Thanks, Randy
Try using the keypress event and trap the return and/or the tab. Then use NODEFAULT in an appropriate manner to leave the cursor in the control after your messagebox(). I usually do something like this:
do case
case nKeyCode = 13
if
NODEFAULT
messagebox()
this.value = ''
endif
endcase
Play withe sequence of events to get the desired behavior...
Eric Kleeman - EDS Consulting Services
MCP Visual FoxPro
MCSD C#.NET
Hua Hin Thailand
Los Angeles California