Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Color of Tab Control 5

Status
Not open for further replies.

EllieFant

MIS
May 15, 2001
513
US
Hi,

I am sure that like the command buttons there is no "official" way to change the colors of them.

I have the tab control style set to buttons, and grey is ok for those, but I have a grey bar that goes across where the buttons reside for the length of the tabcontrol box itself.

I have tried to resize the buttons to make the three buttons be equal in size and cover the grey bar but don't seem to find that property.

Any ideas on how to get rid of the grey bar? Grey just isn't an atractive color :-(

Thanks for your help - I am sure the people at work will be pleased to have something other than grey to look at.
Ellie
**Using Access 97 at work**
**Using Access 2000 at home**

lena.wood@starband.net
 
When I want my Tab control do be a color other than gray, I do a couple of things.

First, I set the tab control background property to transparent (tabs still show gray). Then I hide the tabs and create my own, using labels. When the label is selected I set the Tab property accordingly and increase the height of the selected label a little bit and restore its height when another tab (label) is selected. (Note that the top property of the label will also need to be adjusted a little. I usually base the top property on the tab control itself. That way if I adjust the tab control, the labels are adjused also)

Users can't tell the difference.

That's about the only way I could figure out how to do it.
 
Thanks! That sounds like it will work. I will have to figure out what is what and what goes where. Have never restored the height on a label before...could be interesting.
Ellie
**Using Access 97 at work**
**Using Access 2000 at home**

lena.wood@starband.net
 
Here's how I made it work. First, set the OnClick event of each label to =SelectTab("NameOfTheLabel")

Then, insert this code into the code view of the module. This code keeps track of which label is currently selected (height raised) via the variable mstrLabelSelected. It also basis the top property on the FormHeader rather than the tab control. But, you can do it either way. This should help to get you started. Also, the reason I multiply by 1440 is to convert the units to twips.

Option Compare Database
Option Explicit

Dim mstrLabelSelected As String

Public Function SelectTab(strLabelSelected As String)

If (strLabelSelected <> mstrLabelSelected) Then

Me(mstrLabelSelected).Height = 0.2083 * 1440
Me(mstrLabelSelected).Top = (FormHeader.Height - (0.2083 * 1440))

Me(strLabelSelected).Top = (FormHeader.Height - (0.25 * 1440))
Me(strLabelSelected).Height = 0.25 * 1440

If (strLabelSelected = &quot;NameOf1stTab&quot;) Then
tabCtl.Value = 0
ElseIf (strLabelSelected = &quot;NameOf2ndTab&quot;) Then
tabCtl.Value = 1
End If
End If

mstrLabelSelected = strLabelSelected

End If

End Function
 
I thought about this issue at some stage and you have apparently an answer to the problem. So here is your star. Well done. Cheers

AK
 
Thank you for giving me the code. I save all the code I find interesting here and am amazed at the wealth of information available.

The stars should be &quot;GOLD&quot;, but purple ones will do :) Ellie
**Using Access 97 at work**
**Using Access 2000 at home**

lena.wood@starband.net
 
For some reason this isn't working for me now that I need to use it.

Has anyone used this example and got it to work? I am needing it for a database that needs to have tab control to fit on a single form for all the data entry that needs to be done and I don't want the ugly gray controls.

Maybe I am not changing some of the information in the code correctly. I will have three tabs (Drill, Observation, Finding).

Thanks!!


Ellie
**Using Access 97 at work**
**Using Access 2000 at home**

elliefant@qwest.net
 
I was (am) getting errors every where I turned. I don't think I am changing the information in the module to fit my page names the way I should.

I have found a different way to accomplish this. I will try this method again when I have time to try and play with it a bit more. I guess I am just not sure what I have to change and what stays the same.

Thanks :)

Ellie
**Using Access 97 at work**
**Using Access 2000 at home**

elliefant@qwest.net
 
You say that you &quot;hide the tabs and create your own, using labels&quot;. By 'hiding' them do you mean you just set the 'Visible' field to 'no'?

I'm trying to get a tab to change color depending on its contents. I have a 'notes' field, and I would like the tab to change color (perhaps turn to red) if the field has data in it. I'm assuming I can build upon what's here to get it to work that way, but I'm trying to figure out what you mean by the above statement. Any help would be appreciated.

~Bob
Bob@BobPusateri.com
 
Set the Style property of the Tab control to NONE. Now place your labels above where the tabs would normally sit.
 
Ok I have everything set up and am using the code posted above, however I keep getting an error when I click on a label.

It comes up with &quot;Invalid use of Me keyword&quot; for the 'SelectTab' Function.. Any ideas what I can do to get rid of that?

~Bob
 
Well I've figured that last part out - the code has to be in the module for the form itself, not a 'general' module. Now I am getting an error saying that:

&quot;The control or subform control is too large for this location&quot;.

Unfortunately this doesnt lead me to any help topics either, so I'm trying to figure out what it means and how I can get rid of the problem. I assume it has something to do with the placement of the labels in the tab control, but I'm not sure. Any help would be much appreciated.

~Bob
 
I am using tabs with subforms and although I am keeping the grey buttons, I do use the following to change whether there is data in the Notes section or not.
Private Sub Form_Current()

If IsNull(Me!Notes) Or Me!Notes = &quot;&quot; Then
Me!NotesPage.Caption = &quot;NO NOTES&quot;
Else
Me!NotesPage.Caption = &quot;SEE NOTES&quot;

End If

You may want to even play around with the font color?
B
 
Thx FancyPrairie

Had the same problem but never got around to it - excelent !


Herman

They say that crime doesn't pay... does that mean my job is a crime?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top