Text Font Color based on Tab Selected

WillM

Registered User.
Local time
Today, 11:38
Joined
Jan 1, 2014
Messages
83
Good morning,
We have a navigation page with 5 tabs and several navigation buttons underneath their respective tabs linking to reports.

In the main part of the navigation page we have 17 search parameters (text boxes and combo boxes)that the user can use to sort through all the reports we have in the different tabs.

What we would like to do is to have the label text to change to "red" if one of the 17 fields are "required", remain "black" if it is included in the report but not a mandatory search parameter, or turn "light grey" if that parameter is not included in that report.

For example:
My search parameters are: people, phone, and cars

If I were looking at a report of people that included addresses, phones, etc...name and phone would be required search parameters. However, even though I can search by car, it is not in this particular report and the label text should be greyed out. (If the actual text box could go inactive that would be even better).

I have read about buttons being turned colors based on a drop down box choice, but I have not been able to find anything about using a navigation tab subform button to make the colors change in the main navigation form.

Hopefully I haven't made this too convoluted.

Thanks again!
 
The tabs link to the reports by clicking a button on the tab or the tab is actually displaying the report?
 
I am not quite sure, so let me tell you how it works.
I have a top level tab that says "People", for example.
When I click on that tab, 3 links(they were named navbutton by default) come up under the tab, that when clicked, display the reports in the navigation page subform frame.
 
I actually figured it out! Yay for learning and more researching!

Code:
If (NavButton Is Me.ActiveControl) Then
Me.Parent.Label.ForeColor = RGB(0,0,0)

I dont know how to get the boxes to not be selectable, but this is a good start!
 
Why don't you put the relevant search controls in each individual tab?
 
We thought about that, but we have several reports (close to 20) that potentially can be run from the same search controls. We thought it would be easier on the user base to just put the search parameters in the text boxes/combo boxes at the top (once), then browse through the tabs and select what reports they want in the navigation tabs. If we put the search controls on the tabs they would have to input the information every time they switched tabs, unless I a missing something...which is quite possible.

I am always open to advice!
 
Let me screenshots of the layout.

By the way, you keep saying "we", who's we?
 
We - would be myself and another individual. We work very well as a team and have no issues there.

Here is the attached screenshot of what we were talking about. Sorry for the delay.

The bottom row under the Demographic Reports is where the corresponding buttons are for the reports. Once clicked, the reports display under those three links/buttons, pulling the information (if applicable) from the search controls at the top.
 

Attachments

  • Capture.PNG
    Capture.PNG
    19 KB · Views: 110
I see. I think you've mentioned this to me before.

Is the Tag property of any of the controls in use at the moment? And how do you plan on identifying those fields which are required?
 
No, we are not currently using the tag property for anything. I am open to any suggestions if it makes life easier!

To differentiate between what is "required", what can be "used, but not required", and "not used for this report" is what I had in mind with changing the colors of the labels. Red for required, black for usable, grey for not used.

I tried to use the .lock on the control boxes, but unfortunately I am not versed enough to know how to unlock them between tab switches, so it just locked the boxes until I removed it in the vba.

I really appreciate the help!
 
Now what is most important is the naming convention of your controls so looking at your screenshot pick out one control that can be used in all the tabs and tell me:

1. The name of the control
2. The corresponding name in two of the tabs
 
The name of the control: ContractNo

It is the same all the way through.
 
Consistency, I like that!

So go ahead and enter "Required" (without the quotes) in the Tag property of each of the controls that are required. Only do this for the controls in the tabs. Those used for filtering don't need it.

Two more questions:
1. Are the labels attached to the controls? I.e. when you move the textbox up or down does the label move alone with it.
2. Do you know how to loop through controls?
 
1. Yes, almost all the labels are attached to the controls. We have a few unbound boxes, but better than 99% of them are attached.

2. Not anywhere near as well as I should.
 
The reason I ask about attached controls is because it's relevant to the code you'll implement. If a label is attached, I can refer to it from the textbox it's attached to.

Let's see how you go about looping through the controls on a form.
 
Honestly, I look up how to do it online, beat my head against it until I understand it, and then make it work. I haven't come across a reason to do this yet, so I haven't learned the "how" to do it, though I understand the concept.
 
It's 2 heads, I'm sure you two can come up with something? ;)

I'll start you off and I'll write down the steps. By the way, did you say this is a Navigation form?
 
Haha, yes, we tend to bang our heads while working through problems, but typically we are banging them in the same direction so that helps.

Yes it is a navigation form.
 

Users who are viewing this thread

Back
Top Bottom