Link to home
Start Free TrialLog in
Avatar of BrianLisko
BrianLisko

asked on

MS Graph with Access 2000, Changing Column Colors

Can I change the color of each column using VBA?
Avatar of Markus Fischer
Markus Fischer
Flag of Switzerland image

Yes :)
ASKER CERTIFIED SOLUTION
Avatar of Markus Fischer
Markus Fischer
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bat17
Bat17

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