frank said:
Thanks for your reply. Worked great. One last question.
When I'm looping throught each page objects controls, how
would I assign a reference to that control?
Each of my tab pages contain a list box. From another
form I wanted to set a referance to the list box on the
active tab page. My thinking was to loop through the
active page to get a reference to the list box.
All the controls on the tab pages are also members of the form's
Controls collection, so the easiest way -- if you know the name of the
control you want to reference -- is to just set your reference to the
control by name via a reference to the form. So you could always do
this:
Dim frm As Form
Dim ctl As Control
Set frm = Forms!MyForm
Select Case frm!tabMyTabControl.Value
Case 0 : Set ctl = frm!lstListboxA
Case 1 : Set ctl = frm!lstListboxB
Case 2 : Set ctl = frm!lstListboxC
Case 3 : Set ctl = frm!lstListboxD
End Select
On the other hand, if the listboxes are named in such a way that their
names can be constructed from the page index (or page name), then you
could do something like this:
Dim ctl As Control
With Forms!MyForm
Set ctl = .Controls("lstListbox" &
..Controls("tabMyTabControl").Value)
End With
Failing any of the above, if there can be only one list box on any of
the tab pages, you could loop through the controls on the tab page
looking for one with .ControlType = acListBox. But that seems to me
like more trouble than it's worth.