Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 23rd, 2008, 11:41 AM
Registered User
 
Join Date: Jul 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Conditional Formatting on report in Access

I have a report that pulls data from a table and has the values of Red, Green, Blue, White, Yellow, Purple, Gold. I want the background behind each of those colors to be that color. So if the report shows Blue, then the text is Black in color but the background behind it is blue.

Here is my code thus far:

Select Case Me.PreviousStatus.Value
Case "Blue"
    Me.PreviousStatus.BackColor = 16711680
Case "Green"
    Me.PreviousStatus.BackColor = RGB(0, 255, 0)
Case "Red"
    Me.PreviousStatus.BackColor = RGB(255, 0, 0)
Case Else
    Me.PreviousStatus.BackColor = vbWhite
End Select

 
Old July 23rd, 2008, 11:49 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I assume you are putting this on the Detail section's On Format event. Is this working for you? If not, what errors are being thrown?

I think your readers may have a hard time with seeing black letters against at least that green value.


mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old July 23rd, 2008, 11:56 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Actually, in trying this out, I find you want to specify the same color values. Use the Back Color color picker and insert the values you would have show up in the code, like this:

Select Case Me.Color
    Case "Blue"
        Me.Color.BackColor = 16711680
    Case "Red"
        Me.Color.BackColor = 255
    Case "Green"
        Me.Color.BackColor = 65280
    Case Else
        Me.Color.BackColor = 16777215
End Select

This worked the way you want it to.

mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old August 1st, 2008, 07:33 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

As MMcDonal points out, what exactly is the error or problem? I also suggest using intrinsic constants.

Select Case Me.PreviousStatus
Case "Blue"
    Me.PreviousStatus.BackColor = vbBlue
Case "Green"
    Me.PreviousStatus.BackColor = vbGreen
Case "Red"
    Me.PreviousStatus.BackColor = vbRed
Case Else
    Me.PreviousStatus.BackColor = vbWhite
End Select


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
conditional formatting jeremy1048 Access 4 July 3rd, 2008 11:20 AM
Conditional formatting vemaju Excel VBA 2 June 6th, 2007 04:41 AM
Conditional formatting quit working in access 2003 Dragonlight Access 1 March 16th, 2007 07:07 AM
Access Report Formatting Question arbalest Access 1 December 3rd, 2004 11:15 AM
Conditional Formatting... In Access??? lguzman Access VBA 2 September 23rd, 2004 03:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.