Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Set Focus problem
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00569234
Message ID:
00569932
Views:
26
This is similar to the user cancelling out entirely from the changes. Generally you'll have something like:

IF LASTKEY() = 27
RETURN .T.
ELSE
* Do validation
ENDIF

You could do something similar. Add a property to the form or the control, depending on where it makes the most sense, that you're doing a picklist form. When the picklist form closes, set the property back. So, the validation code would be something like:

IF LASTKEY() = 27 OR This.lPickList
RETURN .T.
ELSE
* Do validation
ENDIF


>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
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform