Make tab visible using vba

aman

Registered User.
Local time
Yesterday, 16:11
Joined
Oct 16, 2008
Messages
1,251
I am using Tab control in Access and I have made one tab invisible by selecting its Property Visible=false.

Now when the button is clicked then I want to make that tab visible using following line of code. Here tbmain is the name of tab control.

Code:
 Me.tbmain.Pages(2).Visible = True

But I'm getting following error message:

runtime error 2467, The expression you entered refers to an object that is closed or doesn't exist.

ANy help will be much appreciated.

Thanks
 
Try it without the "me.tbmain" reference and just use name of the tab control.
 
I was referring to wrong page number that doesn't exist. Its working fine now.
 
Give each page a sensible name like pgUpdates or pgPayments etc. then you can refer to the page by it's name rather than a meaningless reference.
 
You can also refer to the page names directly rather than via the tab control reference once you've named them sensibly.

So to reference the page called pgUpdates as:

me.pgUpdates.Visible=True

You can do this because each page on a tab is also a member of the form's control collection. Hence you can't have two pages with the same name on different tab controls on the same form.

hth
 

Users who are viewing this thread

Back
Top Bottom