TabControl: Independant Size & Color of each Tab/Panel ?

  • Thread starter Thread starter Mel
  • Start date Start date
M

Mel

Just created my first TabControl Form.

Took old Form
Created a Tab Section
Copied parts of old form onto each tab

Now can't set the color of any of the tabs ?

And largest tab seems to define size for all ?

Can I set the color of each tab and it's associated panel/form?

Can I have each tab use different amounts of screen space or must each
be the same size?

thanks for the help.

Mel
 
Mel said:
Just created my first TabControl Form.

Took old Form
Created a Tab Section
Copied parts of old form onto each tab

Now can't set the color of any of the tabs ?

And largest tab seems to define size for all ?

Can I set the color of each tab and it's associated panel/form?

Can I have each tab use different amounts of screen space or must each
be the same size?

thanks for the help.

Mel


The tab control does not have the features you're looking for built-in, but
check out what Steven Lebans has provided at the following URL ...

http://www.lebans.com/tabcolors.htm
 
Thanks Brendan. I just downloaded and unzipped Steve's sample.

No what?

I see code for...

3 Forms
1 Module (Standard Moudle... right?)
2 Class Modules

I think I can study all this code and figgure out what I need and what
I don't need and how to use it but...

Sure would be a timesaver if some quickie instructions were already
available.

We don't need to rotate Tabs or allow the user to change the color of
tabs... just need to color regular old tabs and their associated Form
area.

Thanks,

Mel
 
It's not exactly what you asked for but you can change the form color, which
includes the tab color, when a user clicks on a tab with an event handler
like the example below. The tab control only has one size. Each page in the
tab is the same size. I don't know any way around these limitations, because
that's a basic part of the control.
Private Sub tabSubForm_Change()
Select Case Me![tabSubForm].Value
Case Me![pageContact].PageIndex
Me.Section(0).BackColor = 13434879
Me![subAddress].SetFocus
Case Me![pageAuthor].PageIndex
Me.Section(0).BackColor = 8421440
Case Me![pageReferee].PageIndex
Me.Section(0).BackColor = 16777088
Case Me![pageCorrespondence].PageIndex
Me.Section(0).BackColor = 6697881
Case Me![pageEditor].PageIndex
Me.Section(0).BackColor = 3381555
End Select
End Sub
 
Paul,

I found the "On Change" event for my Tab Control and clicked on the
"..." and then click on Code Builder

My Tab Control is named TabCtl141 AND my Tabs are...
Accounts
People
Orders
Misc

I took a shot at your code as below but need help.

Private Sub tabSubForm_Change() ' I REPLACED tabSubForm
WITH TabCtl141
Select Case Me![tabSubForm].Value ' ditto
Case Me![pageContact].PageIndex '[pageContact]
replaced with my 1st Tab name
Me.Section(0).BackColor = 13434879
Me![subAddress].SetFocus ' [subAddress] ??
what goes here
Case Me![pageAuthor].PageIndex ' [pageAuthor]
replaced with my 2nd Tab Name
Me.Section(0).BackColor = 8421440
Case Me![pageReferee].PageIndex ' [pageReferee]
replaced with my 3rd Tab Name
Me.Section(0).BackColor = 16777088
Case Me![pageCorrespondence].PageIndex 'etc
Me.Section(0).BackColor = 6697881
Case Me![pageEditor].PageIndex 'etc
Me.Section(0).BackColor = 3381555
End Select
End Sub

I've never coded Access and it has been a long time since I've done
any coding.

Thanks for any help.

Mel
 
The code "Me![subAddress].SetFocus" is moving the focus to a particular
subform on the tab. If you don't have subforms on your tab, then you'd
delete that line. So maybe your code is something like:
Private Sub TabCtl141_Change()
'The tab control value tells us which tab page is currently selected
Select Case Me![TabCtl141].Value
Case Me![Accounts].PageIndex 'The Accounts page is selected
Me.Section(0).BackColor = 13434879
Case Me![People].PageIndex 'The People page is selected
Me.Section(0).BackColor = 8421440
Case Me![Orders].PageIndex
Me.Section(0).BackColor = 16777088
Case Me![Misc].PageIndex
Me.Section(0).BackColor = 6697881
End Select
End Sub

The references like "Me![Accounts].PageIndex" have to use the page name, not
the caption. The caption is what is displayed on the tab when the form runs.
You only see the page name on the Other tab of the Properties sheet when you
open the form in Design mode and select that page.
Paul
 
Paul,

I have put in the code from your last post and it is working...
.... except that it changes the color of the form the Tabs are on...
not the color of the Tabs.

I tried to put in the line "set focus" line for my subForm case like
this...

Case Me![People].PageIndex 'The People page is selected
Me![frmPeople].SetFocus 'frmPeple is the subForm on this
tab
Me.Section(0).BackColor = 8421440

Here is my setup for reference...

frmAcctsTabs = my main form with tabs on bottom half
Accounts = Tab 1
Orders = Tab 2
People = Tab 3 (with subForm = frmPeople)
Misc = Tab 4

Maybe I'm creating the dot syntax incorrectly for the subForm ???

I really appriceate the help.

Mel
 
Back
Top