Results 1 to 6 of 6
  1. #1
    ryp is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    11

    Updating X-axis labels in a chart on a report


    I have data in a chart over four groups that are just labeled A, B, C and D in the underlying data. The table wants to label the x-axis of the chart SumOfA, SumOfB, SumOfC, and SumOfD. Ideally I would like to drive these labels by text boxes on a form, but I can't even figure out how to change them manually. I got to the data table in the chart designer and changed them there, and they'd show as changed in design view, but then they weren't changed in report view. I don't mind using VBA if that's required. Thanks for any help.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    AFAIK, can't change these labels in the chart properties. Have to do it in the query that is the RowSource for the chart. Show the sql statement for the RowSource.
    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.

  3. #3
    ryp is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    11
    Thanks!!! I kept double clicking the graph and getting that graph/chart editor, and I was missing that if I just clicked once on the graph, I could open the properties of the graph and see the query there. That helped a lot and solved the problem--I appreciate it! I edited the query to show as follows:

    SELECT [billable],Sum([A]) AS [Curr Week],Sum([B]) AS [Previous Week],Sum([C]) AS [Two Weeks Prior],Sum([D]) AS [Three Weeks Prior] FROM [qryCR_ClientFourPeriod] GROUP BY [billable];

    This worked, but ideally I'd like it to look up the actual dates from a form and use them in the label (so instead of "Curr Week" it could say "Week of 1/14/13"). To achieve this I tried this in the Open event of the report:

    Me.graphHours.RowSource = "SELECT [billable],Sum([A]) AS [Week of " & Format(Forms!frmDates!txtStartA, "mm-dd") & "],Sum([B]) AS [Previous Week],Sum([C]) AS [Two Weeks Prior],Sum([D]) AS [Three Weeks Prior] FROM [qryCR_ClientFourPeriod] GROUP BY [billable];"

    Unfortunately this gave me Run-time error '2455': You entered an expression that has an invalid reference to the property RowSource. My research leads me to think this can't be in the Open event. The On Load didn't work either. Any suggestions on that?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Did you try just putting that SQL with the concatenated variable directly in the chart RowSource?
    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.

  5. #5
    ryp is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    11
    That's a great idea--didn't think of that, but unfortunately it gave an error too. 'Week of " & Forms!frmDates!txtStartA & " is not a valid name. I started wondering if it was a quotes issue, so I tried a few variations (removing the format function, using single quotes, and escaping the quotes), but unfortunately that didn't work either.

    For anybody playing with this type of thing, I did learn that you don't always see an error until you try Print Preview. I would change the SQL, view it in Report View, and nothing would change. Then I'd try to do Print Preview, and that's when I'd see the error or see the SQL change.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Ooops! Just realized that can't be done because field names can't be dynamic in Access queries and since the chart RowSource is an Access query, out of luck.

    I do use VBA to set the RecordSource of a report in the report Open event. Never tried setting the RowSource of a chart. Perhaps in Format event of the section the chart sits in. However, I have doubts that will work.

    True, some report events trigger only in PrintPreview or direct to printer - Format is one of those events. All of my reports are set with PrintPreview as default view.

    You might just have to use a textbox with an expression that references the form control to show the date. You can position the textbox on top of the chart control. Use an opaque background and block out the 'Curr Week' label.
    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. Pivot Chart Data Labels
    By Rick West in forum Forms
    Replies: 5
    Last Post: 08-08-2013, 10:00 AM
  2. Chart axis change with .Chartype changes
    By alangea in forum Programming
    Replies: 2
    Last Post: 05-20-2012, 12:41 PM
  3. Scatter Chart not Showing X-axis Values
    By ward0749 in forum Forms
    Replies: 4
    Last Post: 03-20-2012, 06:37 AM
  4. Perplexing scatter chart x-axis problem
    By whatwouldmattdo in forum Queries
    Replies: 3
    Last Post: 11-28-2011, 09:38 AM
  5. Changing field data into labels on the y-axis
    By slaterino in forum Access
    Replies: 1
    Last Post: 09-28-2010, 03:15 PM

Tags for this Thread

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