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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

toolbars and forms... active control

Status
Not open for further replies.

skuhlman

Programmer
Jun 10, 2002
260
0
0
US
Using VFP7
I have a text field (search) in my toolbar. When text is entered and "return" is pressed or text entered and the find button on the toolbar is pressed, I want the located record to pop up on my form and the first command button on that form to get focus. The search part is working correctly and the form is re-displaying correctly, but the cursor is still sitting up in the search field of the toolbar. Any thoughts?
Thanks
 
In the form's activate event:

Code:
thisform.command1.setfocus

Where command1 is the button you want to receive the focus.
 
skuhlman

Create an object reference for your form with

PUBLIC oForm1
DO FORM Form1 NAME oForm1

Assuming the toolbar has been created from a toolbar class with CreateObject(), the toolbar cannot access your form with THISFORM - instead it uses the object reference.

So to set focus to the form use :-

oForm1.grdGrid1.SetFocus()



FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
Just popped back to update my answer and Chris has beaten me to it. The object reference method will work better. If your form is already loaded and you are calling a requery on it from the toolbar, the activate event on the form won't trigger. My sample will only work if you load the form after clicking your Find button.

BTW Chris, I wasn't suggesting THISFORM would work from the toolbar, if you re-read the solution I gave, the code goes on the form. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top