Open to specific tab page

irish634

Registered User.
Local time
Today, 06:57
Joined
Sep 22, 2008
Messages
230
I know I probably have my syntax messed up here so I figured I'd post it.

I have a "Reports" form with a tab control. I have a "Main" form with various command buttons.

Based on the command button used, I'm trying to open the reports form to a specific tab page in this manner:

Code:
stDocName = "frm_Reports"
stLinkCriteria = "Forms!frm_Reports.TabCtl0 = 1" 
DoCmd.OpenForm stDocName, , , stLinkCriteria
Anyone have any ideas about my syntax? I've tried many variations including " stLinkCriteria = "Forms!frm_Reports.TabCtl0.Value = 1"" to no avail.

I'd like to know if I can do it this way because eventually, I'll end up opening the "frm_reports" form from various data entry forms.

I know I can specify which tab page is active in the Form_Open event of the "frm_Reports" form, so I may end up going that route.

Thanks,
Craig
 
Last edited:
That argument is for opening the form to a particular record, not a tab. Try this:

DoCmd.OpenForm stDocName
Forms!Reports.PageNameHere.SetFocus
 
That argument is for opening the form to a particular record, not a tab. Try this:

DoCmd.OpenForm stDocName
Forms!Reports.PageNameHere.SetFocus

No wonder I couldn't get it to work LOL.
Thank you once again for your help. I appreciate it.
 
No problem. BTW, since "Reports" is a reserved word (it's used the same way "Forms" is in your code), I would avoid using it as an object name.
 
No problem. BTW, since "Reports" is a reserved word (it's used the same way "Forms" is in your code), I would avoid using it as an object name.

Oh, I do. I was just using that as an example. I always use prefixes such as "frm" "tbl" or "rpt"
(I changed the original post to reflect that)
 
I see that this thread is pretty old, but here is a solution with Access2007. This code is attached to the form that I want to close and directs the program to open another form (frm_Utilities) and display a specific tab based on the tab control name (tab_Maintenance).

Private Sub cmd_Close_Click()

DoCmd.Close acForm, Me.Name
vForm = "frm_Utilities"
vTab = "tab_Maintenance"
DoCmd.OpenForm vForm, acNormal
Forms(vForm).Controls(vTab).SetFocus

End Sub

Works well for me.
 

Users who are viewing this thread

Back
Top Bottom