Confusion on Multipage Tabbing

W

WLMPilot

I have two books on Excel VBA and have googled "Multipage Tab" and I am still
in the dark about how to set things up when using this feature. I have
already set up a userform using page1.

The only reference I have made to page1 in my code is below:

Private Sub UserForm_Initialize()
MultiPage1.Value = 0

There is no other reference made anywhere. As best as I can tell, all pages
would be initialized in this section. My code works fine, but I am at a lost
when I start to design other pages. I noticed when I view code from page2,
that all the code from page1 is brought up. Thus my confusion as to how it
is kept separate. Maybe only because the textboxes, combo/Listboxes, etc
will increment. I assume I will not have a textbox1 on both pages.

My question is where and when are references needed regarding multipage
tabbing and how is code like "MultiPage1.Value = 0" used?

Thanks,
Les
 
P

Peter T

and how is code like "MultiPage1.Value = 0" used?

That code would activate the first page of a multipage control named
MultiPage1

The Index of the first page is zero, so to activate the last page you would
do this

MultiPage1.Value = MultiPage1.Count - 1

Afraid I don't really follow the rest of your question, revert back if the
above is not enough.

Regards,
Peter T
 
J

JLGWhiz

Here is a little more info on the MultiPage.

When the multpage is added to a UserForm the Properties
Window shows the name MultiPage1, if it is the first one
added. Then, when you click the tab, Page1, the properties
window changes to show Page1, tab Page2 the properties
window shows page2. This means that each page has its own
properties, but the code module is for the MultiPage only.
The individual pages do not have their own code modules.
You must use a page index reference to control a specific
page: MultiPage1.Pages(0) would be page1.

To add a caption to page2 with code in the UserForm module:

Private Sub UserForm_Initialize()
MultiPage1.Pages(1).Caption = "Flight Plan"
End Sub

The MultiPage provides for event code and each control
which can be applied to individual pages by index number.
For example:

Private Sub MultiPage1_Click(1)
'Do something
End Sub

Would be a click event for page2 of the MultiPage.

Remember that the index number is always one less than
the page number.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top