Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Keep Focus on Text Field
Message
From
10/02/2009 15:25:14
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01380581
Message ID:
01380667
Views:
48
I think maybe Mike was thinking in telling return this.name like stay here?

But like previous message told you, to stay in the text, change the code to the valid method and put Return .F. to keep the focus until proper data is selected.

>I always thought you can only return logical or number from the valid.

>>The Code below is in a txt.LostFocus()
>>
>>If the user gets an error I need to stay focused on that text
>>
>>How is that done??
>>
>>
>>IF !INLIST(UPPER(ALLTRIM(this.Value)),'YES','NO')
>>=MESSAGEBOX('Invalid Data : Must be YES or NO',0 + 16,'Invalid Data')
>>this.Value = ''
>>******************************
>>*-- I NEED TO ADD CODE HERE TO KEEP FOCUS ON THIS TEXT FIELD
>>******************************
>>ELSE
>>thisform.Calculate()
>>ENDIF
>
>Put this code into the Valid event of the control. In the case of bad user entry, do not return .F. (this is standard for causing an invalid condition). If you RETURN .F. then a VFP popup will occur giving an additional error message. In this case RETURN this.Name:
>
>


>IF !INLIST(UPPER(ALLTRIM(this.Value)),'YES','NO')
> =MESSAGEBOX('Invalid Data : Must be YES or NO',0 + 16,'Invalid Data')
> this.Value = ''
> RETURN this.Name
>ELSE
> thisform.Calculate()
>ENDIF
>/PRE>


If you find this message rude or offensive or stupid please don't hesitate to tell me about it. I apologize in advance.

The three chief virtues of a programmer are: Laziness, Impatience and Hubris. (Larry Wall)
John Harold Belalcázar Lozano
Associate Director Of Development
http://www.belvicto.co/
jhbelalc@gmail.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform