tab control question

G

Guest

I have a main form that on it has a tab control. Also on the main form are
buttons, but not on the tab control. The tab control is using single row to
eliminate the multiple row look. Plus there will be many tabs on the tab
control. That is where the buttons come in. The buttons will display the
associated tab(s) depending on the button selected. The tab contol tabs will
be invisible until the button is used. The make visible I can get. What I
would like is when a button is selected, it will make whatever tabs are
showing become invisible then show the tabs selected. It is the making
whatever tabs are showing invisible. I know how to make a tab invisible but
the tab(s) showing will not always be the same. I guess I am looking to see
if someone knows how or has done something like this?
Thanks in advance to anyone who responds.
*** John
 
S

strive4peace

Hi John,

Instead of using a tab control and hiding/unhiding things...
consider this:

make your buttons and a subform object. Depending on which
button is pressed, change the SourceObject for the subform.
Your form will load faster too since it is only loading
one subform

I use a table to define SourceObjects, and define if the
form is to be loaded into the subform control or popup as a
stand-along form. This was my first way of doing it and is
a bit easier to understand:

'--------------------

Private Function SwitchTabs(pIndex As Integer)
On Error GoTo SwitchTabs_error

Me.TabNumber = pIndex
Dim mNumTabs As Integer, i As Integer, mboo As Boolean
Dim Fore1 As Long, Fore2 As Long, Back1 As Long, Back2
As Long

Fore1 = 16777215
Back1 = 11220286
Fore2 = 8388608
Back2 = 16644084

mNumTabs = 6

For i = 1 To mNumTabs
If pIndex = i Then
Me("tab" & i).BackColor = Back1
Me("tab" & i).ForeColor = Fore1
Else
Me("tab" & i).BackColor = Back2
Me("tab" & i).ForeColor = Fore2
End If
Next i

Select Case pIndex
Case 1, 2, 3, 4, 5, 6
Me.TabSubform.Visible = True
Me.TabSubform.SetFocus
End Select
Select Case pIndex
Case 1
Me.TabSubform.SourceObject = "Address_Sub"
Case 2
Me.TabSubform.SourceObject = "Phone_Sub"
Case 3:
Me.TabSubform.SourceObject = "eAddresses_Sub"
Case 4:
Me.TabSubform.SourceObject = "Websites_sub"
Case 5:
Me.TabSubform.SourceObject = "Products_sub"
Case 6:
Me.TabSubform.SourceObject = "FindPeople_sub"
Case Else
Me.TabSubform.SourceObject = ""
Me.Name1.SetFocus
Me.TabSubform.Visible = False
End Select

Exit Function

SwitchTabs_error:
MsgBox Err.Description, , "ERROR " & Err.Number & "
SwitchTabs"
'press F8 to step through lines of code to see where
problem is
If IsAdmin() Then
Stop
Resume
End If

End Function

'----------------------

TabID is an unbound control -- it is set when the form loads
and each time a "tab button" is selected

Instead of command buttons, I use labels, which have more
formatting options

an example of the Onclick event for the Tab2 label is
=SwitchTabs(2)

Sometime, the subforms do not have linking fields, like a
lookup subform

In those cases, I define a calculated control on the subform
aand set it equal to the specified control on the main form
for LinkMasterFields

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 
G

Guest

Crystal, thanks for the info. It sounds intrigueing. I will try it and see
how it goes.
Thanks.
*** John
 
S

strive4peace

you're welcome, John

at the end of the routine, change

'press F8 to step through lines of code to see where
problem is
If IsAdmin() Then
Stop
Resume
End If

to

'press F8 to step through lines of code
'to see where the problem is
'comment next 2 lines out after routine is debugged
Stop
Resume

I usually make an IsAdmin() function so that I can flip it
to false when I am going to deliver an application to users
that would be scared by popping into code...

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 

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