printing graph

  • Thread starter Thread starter hin87_at_yahoo.com
  • Start date Start date
H

hin87_at_yahoo.com

Hi,

I've created a bar chart for my Access report. Basically it just list
employee and their work hours. I would like to display managers in
different bar color. How can I change the color of a bar?


Thank you!
 
Hin:

Stop by our web and look in the Code and Design Tips area under the Reports
sub section to see the tip on "Common Problems and Solutions with Graph".
There's a tip there that shows how to change bar colors. The trick will be
including the field necessary for choosing between managers and employees in
your graph record source.
 
Thanks Steve!!! That looks llike what I needed. How can I determines
the Y-axis value??

How can I determine if I'm at BOB bar??

Example:

JOE |
|
BOB |
|
FRANK |
 
Is it me or is there something wrong with your code.

1) Objchart was never define.
2) After ObjGraph was created, it's not uses in after that.


Dim objGraphAs Object
Dim objDataSeries as Object 'The bar objects
Dim objDataSheet as Object 'The underlying data
Dim intCntValues as Integer, Dim sngValue as Single
Dim i as Integer

Set objGraph= Me!YourChartName.Object
Set objDataSheet = objChart.Application.DataSheet
Set objDataSeries = objChart.SeriesCollection(1) 'only assuming 1
series
intCntValues = objDataSeries.Points.Count 'get the number of bars
for i = 1 to intCntValues
Select Case objDataSheet.Range("A" & i).Value 'XL style syntax
Case < 5
objDataSeries.Points(i).interior.Color = 225 'Red
Case < 15
objDataSeries.Points(i).interior.Color = 16737843 'Blue
Case Else
objDataSeries.Points(i).interior.Color = 16777215 'White
End Select
Next i

Set objDataSeries = Nothing
Set objDataSheet = Nothing
Set objGraph= Nothing
 
there's a little problem with the code, it should read:

Set objGraph= Me!YourChartName.Object
Set objDataSheet = objGraph.Application.DataSheet
Set objDataSeries = objGraph.SeriesCollection(1) 'only assuming 1
 
there's a little problem with the code, it should read:

Set objGraph= Me!YourChartName.Object
Set objDataSheet = objGraph.Application.DataSheet
Set objDataSeries = objGraph.SeriesCollection(1) 'only assuming 1
 
Hi Steve

Sorry to bother you again, but the code doesn't seem to work.

I inserted a chart named "chart5"

Set objGraph= Me!chart5.Object
Set objDataSheet = objGraph.Application.DataSheet
Set objDataSeries = objGraph.SeriesCollection(1) 'only assuming 1

and I get objGraph, objDataSheet, objDataSeries = nothing

I create the chart by creating a new report using the wizard, and then
I select chart as my type of report.

Am I doing something wrong??


Thanks again
Hin
 
Nevermind! Found out my problem. I need to put to code to the
detail.format function instead of the report.open function.

Thank again!!
 
Hi

How can I change the color of the bar based on the Y-Axis?

I would use Range("A" & 1) for the X- Axis, how about the Y-Axis?


Thanks.
 
Range notation is just like that used in Excel, A1, B1 etc. I guess I have
no idea what you mean by Y axis. The value of the field in A1 shows how
far it will go up the Y Axis, so really all you do is evaluate the value in
the data table. If you have multiple series then B1 starts the second
series.
 
Steve,

I found the answer to my questions. Here is the codes I used to find
the y-axis value for my bar graph.

Dim objGraph As Object
Dim objDataSeries As Object 'The bar objects
Dim objdatasheet As Object 'The underlying data
Dim intCntValues As Integer
Dim sngValue As Single
Dim i As Integer
Dim strName As String

Set objGraph = Me!Chart1.Object
Set objdatasheet = objGraph.Application.datasheet
Set objDataSeries = objGraph.SeriesCollection(1) 'only assuming 1
series

intCntValues = objDataSeries.Points.Count 'get the number of bars

For i = 2 To intCntValues + 1
strName = objdatasheet.Cells(i, 1).Value
Select Case Trim(strName)
Case "YourSearchWord"
objDataSeries.Points(i - 1).Interior.Color = 16777215
Case Else
objDataSeries.Points(i - 1).Interior.Color = 16751001
End Select
Next i

Set objDataSeries = Nothing
Set objdatasheet = Nothing
Set objGraph = Nothing
 
Back
Top