Referring to subforms in pages

gellerche

Registered User.
Local time
Today, 08:11
Joined
Jun 19, 2001
Messages
73
I have a form that has a page control on it. The page control has three tabs, and on each tab is a separate subform. I'm using VBA, and I can refer to the first subform (the one on the left with default focus) with:

Forms![Form Name]![Subform name]

, but I can't refer to the other two subforms. When I try the above method (substituting in the subform name I want), Access tells me it can't find it. I have triple checked the spelling of the 2nd and 3rd subforms, and they're correct.

Does anyone have any idea on how I can do this?

Thank you,

Steve Geller
 
You may need to refer to the tab page number (page index). This isn't exactly what you want (I don't know what you're trying to do), but should give you the general idea.

If Me.cmboSchemeType = "KCC/Babtie" Then
Me.tbCtlsfrmDetails1.Pages(0).SetFocus
End If

Where tbCtlsfrmDetails is the name of my tab control.
 
Are you trying to refer to another subform from within the first subform?
 
Thank you both for your help. The problem was that the original designer (I'm doing maintenance) called the subform something different in the Name field than the Source Object field. When I called it what it was looking for, everything was fine.

Thanks again,

Steve Geller
 
I am new to tabs and subforms, but I would like to know how to navigate to the individual tabs. I currently only have one of the 6 tabs holding a subform, but am considering making all 6 subforms if that would make it easier. These tabs make up my menu and when I RETURN TO THE MAIN MENU, it always returns to the first one - and I take it from your post, that is called the tab in focus. I tried to navigate to the one subform with no success. Rather than having the macro open the form MAIN_MENU, I tried to get it to open the subform using the Forms![Form Name]![Subform name] method - but like you mentioned, it did not work. So, for a newbie, how does one go about navigating to these tabs directly? I understand that you are hard coding something, but where is that viewed. If possible a step by step approach would be most appreciated. Thank you very much!
 
shiner:

I'm not sure, but your menu is 6 tabs and you want to know how to refer to the tabs? To answer your other question, you would put the code in the event that would trigger the referral to the subform. For example if you wanted to give a subfom focus after you clicked a button somewhere, in the button's OnClick event (either through VBA or the button's OnClick area under its Properties), you'd enter Forms![Form Name]![Subform name].SetFocus. I apologize if this doesn't answer your question, but I'm not sure what you're asking.
 
thank you! I made a button and stuck the Forms![Form Name]![Subform name].SetFocus into the onCLICK line - and it works. I have both forms open and I can see MAIN_MENU change in the background, but it stays in the background. How can I get the MAIN_MENU screen to show at the front - and be on the appropriate tab?
 

Users who are viewing this thread

Back
Top Bottom