PC Review


Reply
Thread Tools Rate Thread

Changing font colors based on a field value

 
 
Joseph Greenberg
Guest
Posts: n/a
 
      26th Mar 2010
I am programming in Access 2007 but it has to be compatible with Access
2003. I have a master report that has a field called txtTribe. There are two
subreports on this report as well (and two lines, and a memo field). The
report is grouped on txtTribe.

I have the following code in the Report_Load and Report_Page events:

txtFamilyName.ForeColor = RGB(0, 0, 0)
txtTribe.ForeColor = RGB(0, 0, 0)

If txtTribe = "AAA" Then
txtFamilyName.ForeColor = RGB(0, 0, 175)
txtTribe.ForeColor = RGB(0, 0, 175)
End If
If txtTribe = "BBB" Then
txtFamilyName.ForeColor = RGB(0, 125, 0)
txtTribe.ForeColor = RGB(0, 125, 0)
End If

The problem I'm having is that the first page does not get the color
treatment it is supposed to (AAA is the first group). How can I keep the
text black in design mode, and ensure the first page gets the correct
coloring? Just as a note, the group CCC is supposed to be black (there are
only 3 groups) - that's why I have the code at the top to reset everything
to black.

Also, how can I iterate through all the fields and controls on the report
(including the subreports) and make sure that they all get the same color
treatment (the code above changes only 2 fields, I want ALL fields
colorized)?

Thank you.


 
Reply With Quote
 
 
 
 
Duane Hookom
Guest
Posts: n/a
 
      26th Mar 2010
I'm not sure what is where in your report but generally you want to change
properties of controls in code in the On Format event of the section
containing the control.

I can't imagine attempting to use code like this in either the Report Load
or Page events.

--
Duane Hookom
Microsoft Access MVP


"Joseph Greenberg" wrote:

> I am programming in Access 2007 but it has to be compatible with Access
> 2003. I have a master report that has a field called txtTribe. There are two
> subreports on this report as well (and two lines, and a memo field). The
> report is grouped on txtTribe.
>
> I have the following code in the Report_Load and Report_Page events:
>
> txtFamilyName.ForeColor = RGB(0, 0, 0)
> txtTribe.ForeColor = RGB(0, 0, 0)
>
> If txtTribe = "AAA" Then
> txtFamilyName.ForeColor = RGB(0, 0, 175)
> txtTribe.ForeColor = RGB(0, 0, 175)
> End If
> If txtTribe = "BBB" Then
> txtFamilyName.ForeColor = RGB(0, 125, 0)
> txtTribe.ForeColor = RGB(0, 125, 0)
> End If
>
> The problem I'm having is that the first page does not get the color
> treatment it is supposed to (AAA is the first group). How can I keep the
> text black in design mode, and ensure the first page gets the correct
> coloring? Just as a note, the group CCC is supposed to be black (there are
> only 3 groups) - that's why I have the code at the top to reset everything
> to black.
>
> Also, how can I iterate through all the fields and controls on the report
> (including the subreports) and make sure that they all get the same color
> treatment (the code above changes only 2 fields, I want ALL fields
> colorized)?
>
> Thank you.
>
>
> .
>

 
Reply With Quote
 
Joseph Greenberg
Guest
Posts: n/a
 
      26th Mar 2010
Ok, that helped! Thank you! But, why can't you imagine this? What is "wrong"
with this?

"Duane Hookom" <duanehookom@NO_SPAMhotmail.com> wrote in message
news:A08B54B4-4F97-4FD4-9625-(E-Mail Removed)...
> I'm not sure what is where in your report but generally you want to change
> properties of controls in code in the On Format event of the section
> containing the control.
>
> I can't imagine attempting to use code like this in either the Report Load
> or Page events.
>
> --
> Duane Hookom
> Microsoft Access MVP
>
>
> "Joseph Greenberg" wrote:
>
>> I am programming in Access 2007 but it has to be compatible with Access
>> 2003. I have a master report that has a field called txtTribe. There are
>> two
>> subreports on this report as well (and two lines, and a memo field). The
>> report is grouped on txtTribe.
>>
>> I have the following code in the Report_Load and Report_Page events:
>>
>> txtFamilyName.ForeColor = RGB(0, 0, 0)
>> txtTribe.ForeColor = RGB(0, 0, 0)
>>
>> If txtTribe = "AAA" Then
>> txtFamilyName.ForeColor = RGB(0, 0, 175)
>> txtTribe.ForeColor = RGB(0, 0, 175)
>> End If
>> If txtTribe = "BBB" Then
>> txtFamilyName.ForeColor = RGB(0, 125, 0)
>> txtTribe.ForeColor = RGB(0, 125, 0)
>> End If
>>
>> The problem I'm having is that the first page does not get the color
>> treatment it is supposed to (AAA is the first group). How can I keep the
>> text black in design mode, and ensure the first page gets the correct
>> coloring? Just as a note, the group CCC is supposed to be black (there
>> are
>> only 3 groups) - that's why I have the code at the top to reset
>> everything
>> to black.
>>
>> Also, how can I iterate through all the fields and controls on the report
>> (including the subreports) and make sure that they all get the same color
>> treatment (the code above changes only 2 fields, I want ALL fields
>> colorized)?
>>
>> Thank you.
>>
>>
>> .
>>



 
Reply With Quote
 
Duane Hookom
Guest
Posts: n/a
 
      26th Mar 2010
The only reason I have placed code in the On Page event is never related to
data since data and page are not necessarily directly related. My On Page
event code has draw lines on pages using the Line method.

I don't think there is an On Load event for reports in Access 2003 or earlier.

--
Duane Hookom
Microsoft Access MVP


"Joseph Greenberg" wrote:

> Ok, that helped! Thank you! But, why can't you imagine this? What is "wrong"
> with this?
>
> "Duane Hookom" <duanehookom@NO_SPAMhotmail.com> wrote in message
> news:A08B54B4-4F97-4FD4-9625-(E-Mail Removed)...
> > I'm not sure what is where in your report but generally you want to change
> > properties of controls in code in the On Format event of the section
> > containing the control.
> >
> > I can't imagine attempting to use code like this in either the Report Load
> > or Page events.
> >
> > --
> > Duane Hookom
> > Microsoft Access MVP
> >
> >
> > "Joseph Greenberg" wrote:
> >
> >> I am programming in Access 2007 but it has to be compatible with Access
> >> 2003. I have a master report that has a field called txtTribe. There are
> >> two
> >> subreports on this report as well (and two lines, and a memo field). The
> >> report is grouped on txtTribe.
> >>
> >> I have the following code in the Report_Load and Report_Page events:
> >>
> >> txtFamilyName.ForeColor = RGB(0, 0, 0)
> >> txtTribe.ForeColor = RGB(0, 0, 0)
> >>
> >> If txtTribe = "AAA" Then
> >> txtFamilyName.ForeColor = RGB(0, 0, 175)
> >> txtTribe.ForeColor = RGB(0, 0, 175)
> >> End If
> >> If txtTribe = "BBB" Then
> >> txtFamilyName.ForeColor = RGB(0, 125, 0)
> >> txtTribe.ForeColor = RGB(0, 125, 0)
> >> End If
> >>
> >> The problem I'm having is that the first page does not get the color
> >> treatment it is supposed to (AAA is the first group). How can I keep the
> >> text black in design mode, and ensure the first page gets the correct
> >> coloring? Just as a note, the group CCC is supposed to be black (there
> >> are
> >> only 3 groups) - that's why I have the code at the top to reset
> >> everything
> >> to black.
> >>
> >> Also, how can I iterate through all the fields and controls on the report
> >> (including the subreports) and make sure that they all get the same color
> >> treatment (the code above changes only 2 fields, I want ALL fields
> >> colorized)?
> >>
> >> Thank you.
> >>
> >>
> >> .
> >>

>
>
> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing font colors Ken's questions Microsoft Word Document Management 1 16th Nov 2009 01:46 AM
Changing font colors Tiny Microsoft Excel Worksheet Functions 1 3rd Sep 2008 05:10 PM
Changing font colors... JoAnn Paules [MVP] Microsoft Excel New Users 5 1st Dec 2006 12:07 AM
changing font weight based on field value? R Microsoft Access Reports 14 15th Jan 2004 03:24 AM
Changing font colors sectywjc@aol.com Windows XP General 0 4th Nov 2003 05:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:30 PM.