By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,650 Members | 753 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,650 IT Pros & Developers. It's quick & easy.

color subform tab when text boxes are filled

P: 72
Hi,
I am trying to color a subform tab blue or red when 2 of its text boxes are
not null. Here is my code that I tried but it's not working:

If Forms![Centers of Influence subform].First Is Not Null And Forms![Centers
of Influence subform].Last Is Not Null Then
Forms![Centers of Influence subform].Page4781 = RGB(0, 0, 255) 'blue
Else
Forms![Centers of Influence subform].Page4781 = RGB(0, 0, 0) 'black

End If

can anyone tell me what's wrong with my code?
First and Last are the name of the text boxes in the subform.

Thanks in advance
May 18 '07 #1
Share this Question
Share on Google+
9 Replies


puppydogbuddy
Expert 100+
P: 1,923
Hi,
Here is my code that I tried but it's not working:

If Forms![Centers of Influence subform].First Is Not Null And Forms![Centers of Influence subform].Last Is Not Null Then
Forms![Centers of Influence subform].Page4781= RGB(0, 0, 255) 'blue
Else
Forms![Centers of Influence subform].Page4781 = RGB(0, 0, 0) 'black
End If

You need to provide some more details on what "not working" means in this context.....compile error, runtime error, any error messages? Also is this code running from the subform or from the Main Form?

In looking at your code (pending further information), it appears to be a problem with your reference syntax. For example if your code is running from your MainForm, your reference should be like this:

Forms![YourMainForm]![Centers of Influence subform].Form!First

If it is running from your subform, your code syntax should look something like this:
Me!First = .........
May 18 '07 #2

P: 72
Thanks for your reply.
The code is running from the Main Form (On Open) so I changed the code to look like this:

If Forms![Client Maintenance Center Search]![Centers of Influance subform].Form!First Is Not Null And Forms![Client Maintenance Center Search]![Centers of Influance subform].Form!Last Is Not Null Then
Forms![Client Maintenance Center Search]![Centers of Influance subform].Form!Page4781 = RGB(0, 0, 255) 'blue
Else
Forms![Client Maintenance Center Search]![Centers of Influance subform].Form!Page4781 = RGB(0, 0, 0) 'black

End If
I get the following error: " Object required"
May 18 '07 #3

P: 72
sorry the complete error message is:

Run time error '424'
Object required

Thanks
May 18 '07 #4

puppydogbuddy
Expert 100+
P: 1,923
sorry the complete error message is:

Run time error '424'
Object required

Thanks
You did not me which line was highlighted, but I think it would be the line referencing the the tab page because the tab control is not part of the form/subform reference.....it has its own reference as shown:

Genericreference>>>>TabCtl1.Pages.Item(0) >>item is page index
Your reference???>>>>TabCtl4781.Pages.Item(0) >>index for first tab page
May 18 '07 #5

P: 72
Yes the first line is the one highlighted. I am not following on the next lines, how do I include them in my code?

Genericreference>>>>TabCtl1.Pages.Item(0) >>item is page index
Your reference???>>>>TabCtl4781.Pages.Item(0) >>index for first tab page

thanks
May 18 '07 #6

puppydogbuddy
Expert 100+
P: 1,923
Yes the first line is the one highlighted. I am not following on the next lines, how do I include them in my code?
thanks
The first line looks ok. In order to check it out, I need to double check the following:
Main Form Name?
Subform Control Name?
Source Object Name?
Is First what is shown for the name property of the textbox?

The tab page is referenced by tab control name and page index, so when you try to set the color of the first tab page, you should reference as:
Page4781.Pages.Item(0).BackColor = ..... >>>assuming that the tab control name is Page4781.
May 18 '07 #7

puppydogbuddy
Expert 100+
P: 1,923
I did some research and found out that the color properties are not available to the tab control and tabs. The good new is that you can accomplish what you want using a trick. The following link is an excellent "How To" tutorial with code examples and a downloadable working demo file based on the tutorial. Enjoy!

http://www.fontstuff.com/access/acctut12.htm
May 18 '07 #8

P: 72
Thank you so much for all your help.
May 21 '07 #9

puppydogbuddy
Expert 100+
P: 1,923
Thank you so much for all your help.
You are welcome. I'm glad I could help.
May 21 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.