Conditional Formating Circles in a Report - A2003

J

John Taylor

Using A2003 and W2k,

Basically, I want to draw a circle on a report and colour the fillcolor of
the circle depending upon the value in a field called "[Risk]".

I've found some good stuff around but all of it (that I have found) is
basically a "pie chart" with one slice coloured but I can't find any way to
"conditionally" format the back colour.

I've tried to modify the code and, although the circle is perfect, there is
no back fill I just can't get it to work.

The code I'm using to draw the circle - courtesy of Microsoft Developer
Network is this:-


Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Const conPI = 3.14159265359

Dim sngHCtr As Single
Dim sngVCtr As Single
Dim sngRadius As Single

sngHCtr = Me.ScaleWidth / 1.157 ' Horizontal center.
sngVCtr = Me.ScaleHeight / 2 ' Vertical center.
sngRadius = Me.ScaleHeight / 10 ' Circle radius.
Me.Circle (sngHCtr, sngVCtr), sngRadius ' Draw circle.
Me.FillColor = RGB(255, 0, 0) ' Color the circle.
Me.FillStyle = 0 ' Fill the circle


End Sub

That is the first issue (drawing and colouring the circle) - the next is to
conditionally format the back colour of the circle based on the field
"[Risk]" which is simply either 1, 2 or 3 (you probably guessed it - traffic
lights) I really have no idea on how to conditioanally format the circle -
my trial with "iif" and "It, Then, Else" statements have been less than
successfull.

Any help wil be much appreciated - thanks in advance.

John Taylor
 
G

Gina Whipp

John,

When I wanted to do this (using a traffic light), I got an image and used
Paint to get me the three colors I wanted and then used code to call the
image in the color I wanted. True it does require distributing the image
with the application but it seemed easier as I wanted an uncommon image to
change colors.

FYI, if that is your real eMail address you to 'mask' it because the
spammers love to harvest here!

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
 
W

Wayne-I-M

Hi John

On some of my forms and reports I have some Happy Faces, some Sad Faces
(denoteing if a client owes us money - these are a windings font). I also
have some cirlcles of different colours denoteing various things (Marlett
font)

There way I did it was much simpler than yours - yours may be better but I
like things that are kept very simple - less likely to go wrong and easier to
fix if they do.

Anyway

On your report add an unbound text box
Control Source ="n"
Set the font to Marlett
Set the size to whatever you want
Use condidtional formating like this
[Risk]=1 set the colour you want
[Risk]=2 set the colour you want
etc (greeen red amber)

HTH

If you have more than 3 possiblilities then use
If risk = 123 then etc etc etc vbclour=yourcoulr
 
J

John Taylor

Thanks for help from all

I used your method Wayne, you are quite right "simpler is better" as far as
I am concerned.

it worked a treat

JT

Wayne-I-M said:
Hi John

On some of my forms and reports I have some Happy Faces, some Sad Faces
(denoteing if a client owes us money - these are a windings font). I also
have some cirlcles of different colours denoteing various things (Marlett
font)

There way I did it was much simpler than yours - yours may be better but I
like things that are kept very simple - less likely to go wrong and easier
to
fix if they do.

Anyway

On your report add an unbound text box
Control Source ="n"
Set the font to Marlett
Set the size to whatever you want
Use condidtional formating like this
[Risk]=1 set the colour you want
[Risk]=2 set the colour you want
etc (greeen red amber)

HTH

If you have more than 3 possiblilities then use
If risk = 123 then etc etc etc vbclour=yourcoulr

--
Wayne
Trentino, Italia.



John Taylor said:
Using A2003 and W2k,

Basically, I want to draw a circle on a report and colour the fillcolor
of
the circle depending upon the value in a field called "[Risk]".

I've found some good stuff around but all of it (that I have found) is
basically a "pie chart" with one slice coloured but I can't find any way
to
"conditionally" format the back colour.

I've tried to modify the code and, although the circle is perfect, there
is
no back fill I just can't get it to work.

The code I'm using to draw the circle - courtesy of Microsoft Developer
Network is this:-


Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Const conPI = 3.14159265359

Dim sngHCtr As Single
Dim sngVCtr As Single
Dim sngRadius As Single

sngHCtr = Me.ScaleWidth / 1.157 ' Horizontal center.
sngVCtr = Me.ScaleHeight / 2 ' Vertical center.
sngRadius = Me.ScaleHeight / 10 ' Circle radius.
Me.Circle (sngHCtr, sngVCtr), sngRadius ' Draw circle.
Me.FillColor = RGB(255, 0, 0) ' Color the circle.
Me.FillStyle = 0 ' Fill the circle


End Sub

That is the first issue (drawing and colouring the circle) - the next is
to
conditionally format the back colour of the circle based on the field
"[Risk]" which is simply either 1, 2 or 3 (you probably guessed it -
traffic
lights) I really have no idea on how to conditioanally format the
circle -
my trial with "iif" and "It, Then, Else" statements have been less than
successfull.

Any help wil be much appreciated - thanks in advance.

John Taylor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top