setting focus to main form from subform command button

ehdoh

Registered User.
Local time
Today, 13:48
Joined
Jun 24, 2003
Messages
58
Hello,

I have created two command buttons on my subform, one to set the focus back on the main form and the other to set the focus on the next subform. Here are the codes i have set up:

Private Sub nextpgsub1_Click()
Forms!Tabs2!R7toR9Form.SetFocus
End Sub

Private Sub prevpgsub1_Click()
Forms!Tabs2!ID.SetFocus
End Sub

The first, which moves focus from my first subform (R4toR6Form) to my second subform (R7toR9Form), works fine. The second, which is intended to move focus from my first subform (R4toR6Form) back to my mainform (Tabs2), does not work. Any suggestions for how I can de-bug the latter? I will also need to do this on subsequent subforms...

Thank you!
E.
 
If Forms!Tabs2!ID.SetFocus won't work, try this:

Me.Parent.Form.ID.SetFocus

it's just a different way of referring to the parent form when you are running code from the child form (subform).
 
Thank you for the suggestion, dcx693. Alas, I still receive an error message - something like the object or method is not supported.

Any other suggestions???
 
Bum-mer -- still the same object/method not supported message...

Any other suggestions?
 
ID is the name of a control on the main form, right? And it's a type that can receive the focus, right? Like a text box or combo box, not a label control or a hidden control.
 
dc...

That was my next question...

"There is an ID on the Main Form, right?"

:)
 
ID is the name of a control on the main form -- and it is also the name of a control on each subsequent subform -- and it is the field used in link child/master fields.

On the main form, ID is the first field in the tab index. It is not essential that my command button on the subform take one directly back to ID on the main form, but by default since ID is the first in the tab order if one gets back to the start of the main form they will go to the ID field.

ID on the main form is not hidden or locked; it is enabled and always displayed. The only 'special' aspect of this ID field is that it is formatted to be in all caps. Might there be a glitch in what I am trying to do and a field that is in all caps? Any other ideas??

Thanks ever so much for your help!!
 
In the desgin veiw of the Main Form...select the ID Textbox and select Proerties...

What is the Name (not the Control Source)?
 
CALL ME EL STUPIDO!!! Good call, dc -- the name was Text1 whereas the controlsource was ID...

Sorry for all the bother. Thank you so much for all the help!!!
 
Are you absolutely certain the control is called "ID"?
 

Users who are viewing this thread

Back
Top Bottom