CAN ANYONE HELP???? NEED to use vb code Change text color in report

fenerfan

Registered User.
Local time
Today, 14:55
Joined
Dec 3, 2006
Messages
22
:eek: :eek:

Hi Everyone,

There are some absolute aces on this board, and I have another question....


I have a vb button on my form that when pressed produces a print preview of one of my reports.

What It also needs to do is highlght some of the lines in the report, the condition being those items that have expired. I.e. Where Date <Now() .
Is there anything I can do to the button code to be abl to achieve this????


THANKS IN ADVANCE TO ANYONE THAT CAN HELP:cool:
 
The simplest solution would be Conditional Formatting in the report. More info in Help.
 
In the report's Detail_Format event, you want something like this:

Code:
    If Me.CurrentRecord.Fields("Your_Date_Field_Name") < Now Then
        Me.Detail.BackColor = RGB(255, 0, 0) 'Makes the background red
    Else
        Me.Detail.BackColor = RGB(255, 255, 255) 'Leaves the background white
    End If

Explore on your own what other formatting you can do. For the record, I adapted this from a report I wrote a long time ago (probably Access 2000) that alternated gray lines on a report, which looked like this:

Code:
    If Me.CurrentRecord Mod 2 = 0 Then
        Me.Detail.BackColor = RGB(216, 216, 216)
    Else
        Me.Detail.BackColor = RGB(255, 255, 255)
    End If

It should be fine in 2K, 2K2, and 2K3 though.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom