Code to change color of field depending on another fields results

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've searched the newsgroup and not finding an answer to this:

I have a report that's build on a query. In the detail section of the
report I have 4 fields.

[CCNumber]
[CCLead]
[CCTitle]
[CSReceived]

There are only 3 possible options for [CSReceived]

NA
Yes
No

If the [CSReceived] = NA all fields for those records should be Green
= YES all fields for those records should be Blue
= NO all fields for those records should be Red

Can someone help me? I'm not sure how to write this in a procedure.

Thanks in advance.
 
Use conditional formatting. No coding needed. Access has this function
built in.

(Assuming you are using Access 2000 or above).
 
Rick:

Conditional formatting doesn't work in this instance, or I'm missing
something. I want the entire associated records [CCNumber][CCLead][CCTitle]
to change to the specific color depending on what the [CSReceived]
information is.

According to what I'm seeing, Conditional formatting only works per field.

Thanks.

Rick B said:
Use conditional formatting. No coding needed. Access has this function
built in.

(Assuming you are using Access 2000 or above).

--
Rick B



Sondra said:
I've searched the newsgroup and not finding an answer to this:

I have a report that's build on a query. In the detail section of the
report I have 4 fields.

[CCNumber]
[CCLead]
[CCTitle]
[CSReceived]

There are only 3 possible options for [CSReceived]

NA
Yes
No

If the [CSReceived] = NA all fields for those records should be Green
= YES all fields for those records should be Blue
= NO all fields for those records should be Red

Can someone help me? I'm not sure how to write this in a procedure.

Thanks in advance.
 
That is true, but can't you apply the same format to all the fields?

--
Rick B



Sondra said:
Rick:

Conditional formatting doesn't work in this instance, or I'm missing
something. I want the entire associated records [CCNumber][CCLead][CCTitle]
to change to the specific color depending on what the [CSReceived]
information is.

According to what I'm seeing, Conditional formatting only works per field.

Thanks.

Rick B said:
Use conditional formatting. No coding needed. Access has this function
built in.

(Assuming you are using Access 2000 or above).

--
Rick B



Sondra said:
I've searched the newsgroup and not finding an answer to this:

I have a report that's build on a query. In the detail section of the
report I have 4 fields.

[CCNumber]
[CCLead]
[CCTitle]
[CSReceived]

There are only 3 possible options for [CSReceived]

NA
Yes
No

If the [CSReceived] = NA all fields for those records should be Green
= YES all fields for those records should
be
Blue
= NO all fields for those records should
be
Red
Can someone help me? I'm not sure how to write this in a procedure.

Thanks in advance.
 
I just tested this in Northwinds. I highlighted all the controls in a
report. I then opened the Conditional Formatting dialog box. I changed the
first drop-down in Condition1 to say "Expression Is". I then entered an
expression like...

[CSReceived] = NA

and I set the color of the font.

I then clicked the "ADD>>" button and added a second condtion.


You can define three conditions, plus the default, so you should be able to
use this for your scenario.

--
Rick B



Sondra said:
Rick:

Conditional formatting doesn't work in this instance, or I'm missing
something. I want the entire associated records [CCNumber][CCLead][CCTitle]
to change to the specific color depending on what the [CSReceived]
information is.

According to what I'm seeing, Conditional formatting only works per field.

Thanks.

Rick B said:
Use conditional formatting. No coding needed. Access has this function
built in.

(Assuming you are using Access 2000 or above).

--
Rick B



Sondra said:
I've searched the newsgroup and not finding an answer to this:

I have a report that's build on a query. In the detail section of the
report I have 4 fields.

[CCNumber]
[CCLead]
[CCTitle]
[CSReceived]

There are only 3 possible options for [CSReceived]

NA
Yes
No

If the [CSReceived] = NA all fields for those records should be Green
= YES all fields for those records should
be
Blue
= NO all fields for those records should
be
Red
Can someone help me? I'm not sure how to write this in a procedure.

Thanks in advance.
 
Sondra,
I'd just set up an IF Condition in the Detail Print event.
I use this function to alternate gray background on a report...
Const COLOR_SHADE1 = &HDADADA ' The gray color
Me.Line (0, 0)-(3510, Me.Section(0).Height), COLOR_SHADE1, BF

This is B&W, so check out the Line Method in Help, as to how to produce
color backgrounds.
(in my Help there is an code "Example" that uses color background)
hth
Al Camp

Sondra said:
Rick:

Conditional formatting doesn't work in this instance, or I'm missing
something. I want the entire associated records
[CCNumber][CCLead][CCTitle]
to change to the specific color depending on what the [CSReceived]
information is.

According to what I'm seeing, Conditional formatting only works per field.

Thanks.

Rick B said:
Use conditional formatting. No coding needed. Access has this function
built in.

(Assuming you are using Access 2000 or above).

--
Rick B



Sondra said:
I've searched the newsgroup and not finding an answer to this:

I have a report that's build on a query. In the detail section of the
report I have 4 fields.

[CCNumber]
[CCLead]
[CCTitle]
[CSReceived]

There are only 3 possible options for [CSReceived]

NA
Yes
No

If the [CSReceived] = NA all fields for those records should be Green
= YES all fields for those records should
be Blue
= NO all fields for those records should
be Red

Can someone help me? I'm not sure how to write this in a procedure.

Thanks in advance.
 
Back
Top