Changing row colors MSAccess

I need code/instructions on how to change the colors of a row when in the row there is found the following literals in the detail section of the report:

row change color to blue when it finds "Reports"
row change color to yellow when it finds "Meetings"
row change color to orange when it finds "Misc"

thanks in advance
donnie91910Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
what is the NAME property of the control that is being tested?

To find this out: go to the DESIGN view

show the property sheet if it is not already showing by pressing ALT-ENTER
(the property sheet shows additional details for whatever is selected)

then click on the control with company and get the Name from the first property listed on the OTHER (or ALL) tab
donnie91910Author Commented:
Work Code
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
in the Design View:

add a textbox control
delete the corresponding label that comes along with it
stretch the textbox to the the width and the height of your section
send it to the back
-- right-click on it. From the shortcut menu, choose Position > Send to back

now let's add formatting so it will change color

with the new control still selected,
choose the FORMAT ribbon and click Conditional Formatting in the Control Formatting group

click the New Rule command button

choose: Expression Is (instead of Field Value Is)
in the blank box: nz([Work Code]) = "Reports"

and click on the paint bucket icon to pick the blue that you want

click the Apply command button

this takes you back to the first box where you can set up rules

2. click the New Rule command button.
Enter the same expression except modify it to be for "Meetings"
and choose a yellow fill color

3. follow the same process for your 3rd rule

and the click OK to end defining conditional formatting

___________________
In order for the color of the conditional formatted textbox to show, the controls on top of it must be TRANSPARENT.

select the first control and SHIFT-click each of the other controls.

on the FORMAT ribbon, click the dropdown for Shape Fill and choose Transparent.

Save the form and test :)

_______________

does it work?

we aren't done ... because someone might click the textbox behind everything so we need to take care of that ... just want to help you in steps ~
Jeffrey CoachmanMIS LiasonCommented:
The ultimate answer is similar to what crystal (strive4peace) posted

I need code/instructions on how to change the colors of a row
Just FYI, ...you can also do this in code.
(Note that when you say "Row", the equivalent in the report is the detail section.)

You would use code like this on the detail Format event:
If Me.[Work Code] = "Reports" Then
   Me.Section(0).BackColor = vbBlue
ElseIf Me.[Work Code] = "Meetings" Then
   Me.Section(0).BackColor = vbYellow
ElseIf Me.[Work Code] = "Misc" Then
   Me.Section(0).BackColor = 33535
Else
    Me.Section(0).BackColor = vbWhite
End If

As above, you would have to set the "BackStyle" property of the controls to: Transparent
...and if you are using Access 2007 or higher, ...Set the Backcolor Property of the "Detail Section" to: #FFFFFF (White)
And set the "Alternate Back Color" property to: No Color

But this will only work in the report is set to open in "Print Preview"

A bit more convoluted, ...but this will work in versions of Access prior to when Conditional formatting was introduced.
It also can allow for more flexibility in the logic needed for each color.

again, ...just for informational purposes, ...as the first Expert has provided the recommended technique.

results look like this:
samplefor fun, sample db is attached.
;-)

jeffCoachman
Database951.mdb

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
donnie91910Author Commented:
thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.