Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional Formatting of text box in report

Status
Not open for further replies.

xuereveds

Technical User
Apr 8, 2004
17
GB
All,

I am sure this is quick and easy however i am having one of those days where i cant figure a thing out......time to go home i think!

What i am trying to achieve is when my text box in a report has a value greater than 15% the text is highlighted in red......I am sure its V.Easy and will have something to do with the print or format even of the detail section of the report.

Please bear in mind i am working from access 97 and dont have such advances as conditional formatting and the likes.

Thanks in advance of your help.

Scott.

Leadership and learning are indispensable to each other.
John F. Kennedy November 22 1963
 
Here is a 'cheat' which I believe will work in Access 97, as it doesn't use any advanced features.

In your report details section, create two unbound text boxes. In my example, I have called them txtBlack and txtRed. I have called your original bound field containing the percentages YourPercentage.

Set the forecolour of txtRed to be Red (value = 128).

Add this code to the On Format event of the report details section:
Code:
If Me.YourPercentage > 15 Then
    Me.txtRed = Me.YourPercentage
    Me.txtBlack = ""
Else
    Me.txtRed = ""
    Me.txtBlack = Me.YourPercentage
End If
Test the report. You should see (for example)

YourPer
centage txtBlack txtRed
5 5
15 15
20 [red]20[/red]
25 [red]25[/red]

Now set the 'Visible' property of 'YourPercentage' to False
Finally, drag the 'txtRed' field on top of the 'txtBlack' field so they overlap exactly.

When you run the report, you should see the effect you required, e.g.

5
10
[red]20[/red]
[red]25[/red]
etc


Bob Stubbs
 
Bob thanks for that mate

i was just playing with something similar

in

if me.MyValue > 0.15 then
me.MyValue.forecolor = vbred

else
me.MyValue.forecolor = vbblue
end if

which is pretty much what you were doing! like i said having one of those days.....

Thanks for getting back to me so promptly Bob

Leadership and learning are indispensable to each other.
John F. Kennedy November 22 1963
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top