A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Formating Bars based on the value of a bar



 
 
Thread Tools Display Modes
  #1  
Old January 28th, 2008, 08:42 PM posted to microsoft.public.access.reports
billmahon
external usenet poster
 
Posts: 13
Default Formating Bars based on the value of a bar

I have created a bar chart in an access report. I want the bars to change
color based on the value of the specific bar. For example, if the value of a
bar is less than 1, it is red, if it is between 1 and 5, it is yellow, if it
is greater than 5 it is green.

How can I do this?
  #2  
Old January 29th, 2008, 03:24 AM posted to microsoft.public.access.reports
Rob Parker
external usenet poster
 
Posts: 701
Default Formating Bars based on the value of a bar

Seems like an easy problem, but I've just spent a couple of hours playing
with this and I can't make it work. The problem is that the Value property
of the points in the SeriesCollection is not exposed in the VBA interface.
It certainly exists (eg. with the chart in design mode, if you hover the
mouse over a specific bar you see "Series SeriesName Point n Value x.xxx"),
but there does not seem to be any way to access it programmatically.

Rob

"billmahon" wrote in message
...
I have created a bar chart in an access report. I want the bars to change
color based on the value of the specific bar. For example, if the value
of a
bar is less than 1, it is red, if it is between 1 and 5, it is yellow, if
it
is greater than 5 it is green.

How can I do this?



  #3  
Old January 29th, 2008, 06:00 AM posted to microsoft.public.access.reports
Rob Parker
external usenet poster
 
Posts: 701
Default Formating Bars based on the value of a bar

But I won't be beaten easily ;-)

Here's a work-around.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim db As Database
Dim rst As DAO.Recordset
Dim pnt As Object
Dim i As Integer

Set db = CurrentDb
Set rst = db.OpenRecordset(Me.Controls("ChartName").RowSourc e)
With rst
.MoveFirst
For i = 1 To
Me.Controls("ChartName").SeriesCollection("FieldNa me").Points().Count
Set pnt =
Me.Controls("ChartName").SeriesCollection("FieldNa me").Points(i)
Select Case !FieldName
Case Is 1
pnt.Interior.Color = vbRed
pnt.Border.Color = vbRed
Case 1 To 5
pnt.Interior.Color = vbYellow
pnt.Border.Color = vbYellow
Case Is 5
pnt.Interior.Color = vbGreen
pnt.Border.Color = vbGreen
Case Else
End Select
.MoveNext
Next i
End With
Set rst = Nothing
Set db = Nothing
End Sub

What this is doing is opening a recordset, using the same source as the
RowSource of the chart object. Then we simply loop through the number of
points in the chart's SeriesCollection for the required field, get the value
from the recordset which we've opened, and set the interior and border color
for the current point depending on the value in the recordset (which will be
the same as the value of the point in the series).

Simple ...

HTH,

Rob

"Rob Parker" wrote in message
...
Seems like an easy problem, but I've just spent a couple of hours playing
with this and I can't make it work. The problem is that the Value
property of the points in the SeriesCollection is not exposed in the VBA
interface. It certainly exists (eg. with the chart in design mode, if you
hover the mouse over a specific bar you see "Series SeriesName Point n
Value x.xxx"), but there does not seem to be any way to access it
programmatically.

Rob

"billmahon" wrote in message
...
I have created a bar chart in an access report. I want the bars to change
color based on the value of the specific bar. For example, if the value
of a
bar is less than 1, it is red, if it is between 1 and 5, it is yellow, if
it
is greater than 5 it is green.

How can I do this?





  #4  
Old January 29th, 2008, 04:09 PM posted to microsoft.public.access.reports
billmahon
external usenet poster
 
Posts: 13
Default Formating Bars based on the value of a bar

This worked like a charm. Thank you so much for your efforts.

One last thing, I have data labels for each bar (the value of the bar), how
do I get them to change to the appropriate color (same as the bar).

"Rob Parker" wrote:

But I won't be beaten easily ;-)

Here's a work-around.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim db As Database
Dim rst As DAO.Recordset
Dim pnt As Object
Dim i As Integer

Set db = CurrentDb
Set rst = db.OpenRecordset(Me.Controls("ChartName").RowSourc e)
With rst
.MoveFirst
For i = 1 To
Me.Controls("ChartName").SeriesCollection("FieldNa me").Points().Count
Set pnt =
Me.Controls("ChartName").SeriesCollection("FieldNa me").Points(i)
Select Case !FieldName
Case Is 1
pnt.Interior.Color = vbRed
pnt.Border.Color = vbRed
Case 1 To 5
pnt.Interior.Color = vbYellow
pnt.Border.Color = vbYellow
Case Is 5
pnt.Interior.Color = vbGreen
pnt.Border.Color = vbGreen
Case Else
End Select
.MoveNext
Next i
End With
Set rst = Nothing
Set db = Nothing
End Sub

What this is doing is opening a recordset, using the same source as the
RowSource of the chart object. Then we simply loop through the number of
points in the chart's SeriesCollection for the required field, get the value
from the recordset which we've opened, and set the interior and border color
for the current point depending on the value in the recordset (which will be
the same as the value of the point in the series).

Simple ...

HTH,

Rob

"Rob Parker" wrote in message
...
Seems like an easy problem, but I've just spent a couple of hours playing
with this and I can't make it work. The problem is that the Value
property of the points in the SeriesCollection is not exposed in the VBA
interface. It certainly exists (eg. with the chart in design mode, if you
hover the mouse over a specific bar you see "Series SeriesName Point n
Value x.xxx"), but there does not seem to be any way to access it
programmatically.

Rob

"billmahon" wrote in message
...
I have created a bar chart in an access report. I want the bars to change
color based on the value of the specific bar. For example, if the value
of a
bar is less than 1, it is red, if it is between 1 and 5, it is yellow, if
it
is greater than 5 it is green.

How can I do this?






  #5  
Old January 29th, 2008, 09:05 PM posted to microsoft.public.access.reports
Rob Parker
external usenet poster
 
Posts: 701
Default Formating Bars based on the value of a bar

Like this (you'll need similar in each Case construction):
...
Case Is 1
pnt.Interior.Color = vbRed
pnt.Border.Color = vbRed
Me.Controls("ChartName").SeriesCollection("FieldNa me").DataLabels(i).Font.Color
= vbRed
...

Note: yellow text (on a white background) is not easy to see :-)

Again, HTH,

Rob


"billmahon" wrote in message
...
This worked like a charm. Thank you so much for your efforts.

One last thing, I have data labels for each bar (the value of the bar),
how
do I get them to change to the appropriate color (same as the bar).

"Rob Parker" wrote:

But I won't be beaten easily ;-)

Here's a work-around.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim db As Database
Dim rst As DAO.Recordset
Dim pnt As Object
Dim i As Integer

Set db = CurrentDb
Set rst = db.OpenRecordset(Me.Controls("ChartName").RowSourc e)
With rst
.MoveFirst
For i = 1 To
Me.Controls("ChartName").SeriesCollection("FieldNa me").Points().Count
Set pnt =
Me.Controls("ChartName").SeriesCollection("FieldNa me").Points(i)
Select Case !FieldName
Case Is 1
pnt.Interior.Color = vbRed
pnt.Border.Color = vbRed
Case 1 To 5
pnt.Interior.Color = vbYellow
pnt.Border.Color = vbYellow
Case Is 5
pnt.Interior.Color = vbGreen
pnt.Border.Color = vbGreen
Case Else
End Select
.MoveNext
Next i
End With
Set rst = Nothing
Set db = Nothing
End Sub

What this is doing is opening a recordset, using the same source as the
RowSource of the chart object. Then we simply loop through the number of
points in the chart's SeriesCollection for the required field, get the
value
from the recordset which we've opened, and set the interior and border
color
for the current point depending on the value in the recordset (which will
be
the same as the value of the point in the series).

Simple ...

HTH,

Rob

"Rob Parker" wrote in
message
...
Seems like an easy problem, but I've just spent a couple of hours
playing
with this and I can't make it work. The problem is that the Value
property of the points in the SeriesCollection is not exposed in the
VBA
interface. It certainly exists (eg. with the chart in design mode, if
you
hover the mouse over a specific bar you see "Series SeriesName Point n
Value x.xxx"), but there does not seem to be any way to access it
programmatically.

Rob

"billmahon" wrote in message
...
I have created a bar chart in an access report. I want the bars to
change
color based on the value of the specific bar. For example, if the
value
of a
bar is less than 1, it is red, if it is between 1 and 5, it is yellow,
if
it
is greater than 5 it is green.

How can I do this?







  #6  
Old January 29th, 2008, 09:25 PM posted to microsoft.public.access.reports
billmahon
external usenet poster
 
Posts: 13
Default Formating Bars based on the value of a bar

Awesome. Thanks again, I greatly appreciate the help.

"Rob Parker" wrote:

Like this (you'll need similar in each Case construction):
...
Case Is 1
pnt.Interior.Color = vbRed
pnt.Border.Color = vbRed
Me.Controls("ChartName").SeriesCollection("FieldNa me").DataLabels(i).Font.Color
= vbRed
...

Note: yellow text (on a white background) is not easy to see :-)

Again, HTH,

Rob


"billmahon" wrote in message
...
This worked like a charm. Thank you so much for your efforts.

One last thing, I have data labels for each bar (the value of the bar),
how
do I get them to change to the appropriate color (same as the bar).

"Rob Parker" wrote:

But I won't be beaten easily ;-)

Here's a work-around.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim db As Database
Dim rst As DAO.Recordset
Dim pnt As Object
Dim i As Integer

Set db = CurrentDb
Set rst = db.OpenRecordset(Me.Controls("ChartName").RowSourc e)
With rst
.MoveFirst
For i = 1 To
Me.Controls("ChartName").SeriesCollection("FieldNa me").Points().Count
Set pnt =
Me.Controls("ChartName").SeriesCollection("FieldNa me").Points(i)
Select Case !FieldName
Case Is 1
pnt.Interior.Color = vbRed
pnt.Border.Color = vbRed
Case 1 To 5
pnt.Interior.Color = vbYellow
pnt.Border.Color = vbYellow
Case Is 5
pnt.Interior.Color = vbGreen
pnt.Border.Color = vbGreen
Case Else
End Select
.MoveNext
Next i
End With
Set rst = Nothing
Set db = Nothing
End Sub

What this is doing is opening a recordset, using the same source as the
RowSource of the chart object. Then we simply loop through the number of
points in the chart's SeriesCollection for the required field, get the
value
from the recordset which we've opened, and set the interior and border
color
for the current point depending on the value in the recordset (which will
be
the same as the value of the point in the series).

Simple ...

HTH,

Rob

"Rob Parker" wrote in
message
...
Seems like an easy problem, but I've just spent a couple of hours
playing
with this and I can't make it work. The problem is that the Value
property of the points in the SeriesCollection is not exposed in the
VBA
interface. It certainly exists (eg. with the chart in design mode, if
you
hover the mouse over a specific bar you see "Series SeriesName Point n
Value x.xxx"), but there does not seem to be any way to access it
programmatically.

Rob

"billmahon" wrote in message
...
I have created a bar chart in an access report. I want the bars to
change
color based on the value of the specific bar. For example, if the
value
of a
bar is less than 1, it is red, if it is between 1 and 5, it is yellow,
if
it
is greater than 5 it is green.

How can I do this?








  #7  
Old July 31st, 2009, 09:18 AM posted to microsoft.public.access.reports
hughess7
external usenet poster
 
Posts: 190
Default Formating Bars based on the value of a bar

Hi, can you help please? This is also what I want to do but I think my
rowsource is maybe different and I just want clarification on this and some
further explanation please...

I have two rows of data in the datasource, one is based on dealer values and
the 2nd is national values (always 100). The National values are displayed as
a trend line, the dealer values in bar columns (is this the points?). I want
them red if over 100 and blue if under 100. Trying to use this example I get
them all in the same colour, dependant on the values but I want them to
colour depending on each individual columns value?

Thanks in advance for any help.
Sue


"Rob Parker" wrote:

But I won't be beaten easily ;-)

Here's a work-around.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim db As Database
Dim rst As DAO.Recordset
Dim pnt As Object
Dim i As Integer

Set db = CurrentDb
Set rst = db.OpenRecordset(Me.Controls("ChartName").RowSourc e)
With rst
.MoveFirst
For i = 1 To
Me.Controls("ChartName").SeriesCollection("FieldNa me").Points().Count
Set pnt =
Me.Controls("ChartName").SeriesCollection("FieldNa me").Points(i)
Select Case !FieldName
Case Is 1
pnt.Interior.Color = vbRed
pnt.Border.Color = vbRed
Case 1 To 5
pnt.Interior.Color = vbYellow
pnt.Border.Color = vbYellow
Case Is 5
pnt.Interior.Color = vbGreen
pnt.Border.Color = vbGreen
Case Else
End Select
.MoveNext
Next i
End With
Set rst = Nothing
Set db = Nothing
End Sub

What this is doing is opening a recordset, using the same source as the
RowSource of the chart object. Then we simply loop through the number of
points in the chart's SeriesCollection for the required field, get the value
from the recordset which we've opened, and set the interior and border color
for the current point depending on the value in the recordset (which will be
the same as the value of the point in the series).

Simple ...

HTH,

Rob

"Rob Parker" wrote in message
...
Seems like an easy problem, but I've just spent a couple of hours playing
with this and I can't make it work. The problem is that the Value
property of the points in the SeriesCollection is not exposed in the VBA
interface. It certainly exists (eg. with the chart in design mode, if you
hover the mouse over a specific bar you see "Series SeriesName Point n
Value x.xxx"), but there does not seem to be any way to access it
programmatically.

Rob

"billmahon" wrote in message
...
I have created a bar chart in an access report. I want the bars to change
color based on the value of the specific bar. For example, if the value
of a
bar is less than 1, it is red, if it is between 1 and 5, it is yellow, if
it
is greater than 5 it is green.

How can I do this?






 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:47 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.