I'm assuming you're (a) MYVARIABLE is a public variable since it would go out of scope otherwise, and (b) really meant SetFocus, not GetFocus in the code you posted.
Instead of using a public variable (public variables are generally considered bad practice), add a custom property to the form to hold the object reference (oLastObject for example).
In the when of your button, set the reference using:
ThisForm.oLastObj = ThisForm.ActiveControl
In the click of the button:
Insert Your Code to Replace Values here
ThisForm.oLastObj.SetFocus()
And finally, in the QueryUnload:
thisform.oLastObj = .NULL.
return .t.
>A better description of the problem:
>The textbox has focus...
>I have STORE THIS.MYNAME (MYNAME is the object name of the textbox)
>TO MYVARIABLE in the textbox gotfocus code...
>The user clicks a button with the click event code THISFORM.MYVARIABLE.GOTFOCUS to return focus to the textbox, but the textbox does not receive focus.
>I also tried THISFORM.&MYVARIABLE.GOTFOCUS
kenweber
GCom2 Solutions
Microsoft Certified Professional