Reputation: 31
Basically, I have a multipage for different departments of information called mpageTabsMain.
Inside each page of the multipage is a tabstrip, that contains tabs that represents different people.
What i'm doing for testing right now is using a button click to fill in a textbox's text on my 2nd page of the multipage.
mpageTabsMain.Pages(1).TextBox1.Text = "test"
However, what this does is it fills in the TextBox1's text for every Tab (person) in the TabStrip.
How do I refer to a particular tab (person)'s control in a TabStrip so that only that one is filled?
Thanks.
Upvotes: 2
Views: 1013
Reputation: 9948
1) You can't have the same control names within a UserForm.
2) If you want to handle different controls for each page (e.g. TextBox1
on page1, TextBox2
on page2) you should use a Multipage
control and maybe this would be the better choice for your requirements.
3) A Tabstrip
control makes sense for pages with a similar or identical layout, but uses ONE set of controls only. So if you assign a value to your TextBox1.Text
property without further conditions
(i.e. distinguishing between the different kinds of pages) you'll get the same text for the same TextBox1
control independantly of which page you are addressing. Though a Tabstrip
can possibly
facilitate to write comparable code for only a few controls (distinguishing at which page you are), it could be the harder part to code.
Addendum (refers to comment below)
OK, you are using a TabStrip
within a Multipage
and apparently you want to display a tabstrip tab for every person. (BTW, I wouldn't do that, you could just change the tab name dynamically, but that isn't the question).
There is no more than one unique
TextBox1
control in the whole UserForm. AsTextBox1
is a unique Name, and instead your long code line it's sufficient to assign a string value viaMe.TextBox1.Text = "test content for Person A"
referring to a current tab view of Person A orTextBox1.Text = "test content for Person B"
according to another tab view and another tab value. But it's the sameTextBox1
in any case.Me
stands for the UserForm itself inside the Userform code module. You only 'fake' the view to this text (control) depending on the tab situation and are responsible to write it back properly or save it according to the actual tab view :-;
Upvotes: 1