Results 1 to 2 of 2
  1. #1
    darkwind is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2017
    Location
    Central U.S.
    Posts
    48

    Pie Chart Coloring

    Hi all,



    I have a procedure which dictates the colors of a pie chart in a report. This is used to sync colors across different groups in the report; I.E., Item 1 in Group 1 should be the same color as it is in Group 7. The particular line used to set the color is:

    Code:
    Me.Graph.SeriesCollection(1).Points(i).Interior.Color = rs("chartColor")
    Obviously the default coloring would simply assign colors in order of the Items in the group. Since different groups have different Items, they wouldn't normally be the same color. My procedure works correctly to correct this, however, it is very slow- after some testing, it takes about half a second to run just the one line in question! The report runs without this line in about 22 seconds, but due to the number of times I have to set these colors, takes 56 seconds with it enabled. I have definitively ruled out the loop as the course of the issue, as I tested by simply commenting out the listed line. Does anyone know of a different method of setting this color programatically?

    Here's the full procedure for reference:

    Code:
    'Recordset with all Items from across the report
    Set rs = CurrentDb.OpenRecordset("SELECT DISTINCT Item FROM qryReport ORDER BY Item")
    
    'Recordset with desired Chart Colors
    Set rs2 = CurrentDb.OpenRecordset("SELECT chartColor FROM tblChartColors")
    
    'Recordset with all Items in the Group
    Set rs3 = CurrentDb.OpenRecordset("SELECT Item FROM qryReport WHERE Group =" & Me.txtGroup & " ORDER BY Item")
    If (rs.EOF AND rs.BOF) OR (rs2.EOF AND rs2.BOF) OR (rs3.EOF AND rs3.BOF) Then GoTo PROC_ERR
    rs.MoveFirst
    rs2.MoveFirst
    rs3.MoveFirst
    
    'Tracks which Item we are on, which is also the position in the SeriesCollections
    i = 0
    Do Until rs3.EOF
        Do Until rs("Item") = rs3("Item")
           If rs.EOF Then
                rs.MoveFirst
                rs2.MoveFirst
            Else
                rs.MoveNext
    
                If rs2.EOF Then
                    rs2.MoveFirst
                Else
                    rs2.MoveNext
                End If
            End If
        Loop
        rs3.MoveNext
        If rs2.EOF Then rs2.MoveFirst
        i = i + 1
        Me.Graph282.SeriesCollection(1).Points(i).Interior.Color = rs2("chartColor")
        Me.Graph199.SeriesCollection(1).Points(i).Interior.Color = rs2("ChartCOlor")
    Loop


    Thanks in advance.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,893
    Not that I know of. I experimented with this once and it was the only method I could find. https://www.accessforums.net/showthread.php?t=29178
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Limit chart to date range , Chart isnt updating .
    By fluffyvampirekitten in forum Access
    Replies: 5
    Last Post: 06-30-2015, 12:27 AM
  2. Coloring Certain Fields when Auditing
    By Z1nkstar in forum Access
    Replies: 9
    Last Post: 06-16-2014, 03:44 PM
  3. Coloring Buttons not working
    By justphilip2003 in forum Forms
    Replies: 8
    Last Post: 05-11-2013, 08:10 AM
  4. Coloring a combobox as error message?!
    By Lidwina in forum Forms
    Replies: 1
    Last Post: 03-03-2011, 11:12 AM
  5. Replies: 2
    Last Post: 07-12-2010, 05:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums