Set Focus on a Form with 4 subforms

JPritch

Registered User.
Local time
Today, 14:26
Joined
Jan 7, 2005
Messages
54
My main form has four command buttons that when clicked will make visible one of four subforms.

I can switch freely about the subforms by clicking on each of the buttons. However, when I place the cursor in a subform(and thus give it Focus), and then attempt to select another button to open another subform, I get the dreaded "can't hide a control that has the focus" error message.

What type of code should I use and where exactly should I be putting it?

I've tried setting focus to another subform in the OnClick event of my buttons, but that doesn't seem to be working.
 
Well, after an extensive search...I think I've got it.

I ran across a post by either Ghudson or Leo, and they used a hidden text box to set focus to (property is still visible, but altering it's size and color to where you can't see it), and then setting your focus to it.

I had no other controls on the main form to set focus on. Only buttons are on my main form and setfocus didn't like them.

Things seem to be working fine so far. Any potential drawbacks?
 
Only drawback I see is that the user will see the curson on this field and will have to move from it. Did you try simply setting the focus back to the main form. Try the following in place of your code that moves the focus to your small control:
Forms!MasterFormName.SetFocus
 

Users who are viewing this thread

Back
Top Bottom