MSAccess-barchart-colorchange based on xaxis value in vba

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • baba
    New Member
    • Nov 2011
    • 16

    MSAccess-barchart-colorchange based on xaxis value in vba

    Query ran to create barchart :Select jobname,count(* ) from table 1;
    In my bargraph,
    X axix shows jobnames.
    Y axis shows counts.
    All the bars in barchart are of same color.

    Currently the generated bar graph shows all jobs joba,jobb,jobc, jobd in the same color.
    My requirement:


    Is it possible to write some code like this to change the bar colors after the bargraph is generated by my query....

    Step 1.Generate the bargraph by the query
    Step 2.Change the barcolor of each bar based on the jobname value .

    I have written the logic of what I want but I dont know the syntax and how to implement it .Kindly advise

    With Forms!Form2.Gra ph1
    For i = 1 to Forms!Form2.Gra ph1.SeriesColle ction.Count
    If Forms!Form2.Gra ph1.SeriesColle ction(i).Xaxis. value = "joba"
    then Forms!Form2.Gra ph1.SeriesColle ction(i).interi or.co lor = "Green"
    end if

    If Forms!Form2.Gra ph1.SeriesColle ction(i).Xaxis. value = "jobb"
    then Forms!Form2.Gra ph1.SeriesColle ction(i).interi or.co lor = "Blue"
    end if

    If Forms!Form2.Gra ph1.SeriesColle ction(i).Xaxis. value = "jobc"
    then Forms!Form2.Gra ph1.SeriesColle ction(i).interi or.co lor = "yellow"
    end if

    Next i

    End with
Working...