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

Changing focus on an active form

Status
Not open for further replies.

accessisnew

Technical User
May 25, 2006
15
US
I have a VBA module that populates controls in an unbound form with data from a table. The module then opens the form which also contains a visible/enabled command button (Command1)that the user clicks to send selected lines from the form (user clicks check boxes to indicate which lines)back to the module for additional processing.

I want to disable the active command button (Command1) and make it invisible so that I can redisplay the form with additional data and a second command button (Command2) visible with the focus on a text field (Text1). The SetFocus and GoToControl will not allow me to change the focus from the first command button.

What can I do to change the focus to the text field (Text1)?
 
You cannot set focus on an object that is not set to visible. Check the order in which you are issuing the commands. Assuming that, when you first open the form, Command2 is not visible and Command1 has the focus:

1st - make Command2 visible.
2nd - set focus on Command2.
3rd - make Command1 invisible.



Randy
 
Thanks so much! The proper sequencing worked like a charm.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top