Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can't set Focus from a button's click even.

Status
Not open for further replies.

andreateh

Programmer
Jul 19, 2003
83
SG
I got i one entry from which is set to modeless. When user add record, another form which is set to modal is call by the modeless form from a textbox valid event. When i click the save button in the modal form. An erros message come out.

cannot call set focus from within a When,Valid,rangehigh,rangelow event

In the Save button's click event i put code below.
Code:
WITH thisform.textbox3 
	IF .value <= 0
		MESSAGEBOX(&quot;Error&quot;)
		.SetFocus() &&<--Erorr happen here
		RETURN 
	ENDIF 
ENDWITH

can some body help me ?
 
why not use RETURN 0 to retain the focus to the current control?


kilroy [trooper]
philippines
&quot;and that's what we call creativity...&quot;
 
what i meant was, in the VALID event of the textbox itself, i d something like:

Code:
if this.value <= 0
     messagebox(&quot;ERROR!&quot;)
     return 0
endif


kilroy [trooper]
philippines
&quot;and that's what we call creativity...&quot;
 
The problem is not that you can't call SetFocus from the button's click, but that the click was called from another object's Valid method in the calling stack.

Can you move the code in the textbox's valid to its LostFocus?


-BP (Barbara Peisch)
 
Thanks for help.I decide to move the code to lost focus event.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top