MS Graph with Access 2000, Changing Column Colors

Can I change the color of each column using VBA?
BrianLiskoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

harfangCommented:
Yes :)
0
harfangCommented:
The easiest way to learn how to change a graph by using VB is to start Excel, create a graph, start the macro recorder and then change the graph. The object model seems identical.

Then, if your graph is called uofChart, Me.uofChart.Object returns a chart object, which you can manipulate... For example:

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

    With uofChart.Object.Axes(1)
   
        .MinimumScale = CDbl(#1/1/2004 12:00:00 PM#)
        .MaximumScale = CDbl(#1/2/2004 6:00:00 PM#)
        .MajorUnit = CDbl(#4:48:00 AM#)   ' or 1/5
        .TickLabels.NumberFormat = "d h:mm"
       
    End With

End Sub

You will have to figure out the Series collection and the Data Points collection (or something like that), but it shouldn't be too hard.

Good Luck
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bat17Commented:
Here is some code I use for colouring a graph based on results.
The code is called from the Detail_Format event

Private Sub ColourParetoGraph()
Dim dbs As Database
Dim intPointCount As Integer
Dim intPointColour As Long
Dim qdf As QueryDef
Dim prm As Parameter
Dim rstGraphData As Recordset
Dim intWeek As Integer

    On Error Resume Next
    ' Return reference to current database.
    Set dbs = CurrentDb
    ' Open dynaset-type Recordset object.
    Set qdf = dbs.QueryDefs("qryWeeklyParetoGraph")
    For Each prm In qdf.Parameters
        prm.Value = Eval(prm.Name)
    Next prm
   
    Set rstGraphData = qdf.OpenRecordset(dbOpenDynaset)
    ' Set current record.
    rstGraphData.MoveFirst
   
For intPointCount = 1 To 10
    If rstGraphData("Improved") > 0 Then
        intPointColour = QBColor(12) ' red
    Else
        intPointColour = QBColor(10)
    End If
    Graph53.SeriesCollection(1).Points(intPointCount).Interior.Color = intPointColour
    rstGraphData.MoveNext
Next

rstGraphData.Close
Set rstGraphData = Nothing
Set qdf = Nothing
Set dbs = Nothing
End Sub

HTH

Peter
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.