Hi Craig!
This question made me think of a similar question I am constantly struggling with. I think I've asked it one way or the other a dozen times, but maybe you have a suggestion.
What about the situation where you want to know why the user is exiting the field before you decide whether or not to prevent them? For example, we have a custom lookup class that utilizes a grid. If the user keys in an invalid entry, and then decides he needs to use the lookup to get the valid entry, we have to do one of two things. We either clear the invalid value with every validation failure, or we have to put the data field and the button launching the lookup in a container together and run the validation in the lostfocus of the container. (I think that works).
Do you have a suggestion for a better way of doing this?
As always, thanks for your help!
>Is there a reason you aren't using the Valid method to do the validation. Returning a 0 or .F. there will keep focus on the control.
>
>>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