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)