Results 1 to 5 of 5
  1. #1
    MatthewR is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2015
    Posts
    118

    Dynamic Chart Title in Report

    Re: https://www.accessforums.net/reports...ort-23126.html

    Hey, folks. I'm trying to adjust my chart title through VBA, like in the above thread, and it's not working for me. Can you help me figure out what I'm doing wrong?



    I have a form named StatRelationshipsYear, and a bar chart named RelationshipYearChart. And in the Format event of the Detail section, I put this code:

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Me.RelationshipYearChart.ChartTitle.Text = "Test"
    End Sub

    I open the form, and I get nada. The code doesn't appear to have any effect. Any ideas?

    Thanks for your help, people.

    Matt

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Why use code? Why not just set title in chart design?

    Report Format event only runs when report sent to printer or PrintPreview.

    Thread title indicates a report but your narrative says form - which is it?
    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
    MatthewR is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2015
    Posts
    118
    Thanks very much for the response. My mistake on the original post- it's a report, not a form.

    I'm using code here because the chart is based on a parameter query. And I want the parameter to be part of the chart's title.

    Is there any way to do that in Report View?

    Also, with the current code, when I go to Print Preview mode, I get "Run-time error 1004: Unable to set the Text property of the ChartTitle Class."

    So, it's not working for me in either view.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Could use a textbox sitting on top of the chart. I've gone that route as well.

    I don't know why the code fails. I've never tried to programmatically set the chart title, only the axis titles.

    Code:
            With Me.gphDensity
            .Axes(xlValue, xlPrimary).HasTitle = True
            If Forms!DataSoilsAgg!Metric = True Then
                .Axes(xlValue, xlPrimary).AxisTitle.Text = "Max. Dry Density, Kg/cu.m"
            End If
            .Axes(xlCategory, xlPrimary).HasTitle = True
            If Forms!DataSoilsAgg!Metric = True Then
                .Axes(xlCategory, xlPrimary).AxisTitle.Text = "Percent Passing 4.75 mm Sieve"
            End If
            End With
    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
    MatthewR is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2015
    Posts
    118
    Okay, thanks for the tip!

    Initially, I didn't want to use text boxes because I wanted the user to be able to export the chart to Excel, and play with it.

    Now, I'm realizing that you can't really export a chart to excel- you can only export data. True?

    If so, I guess I might as well use text boxes, haha.

    And I'll give the axis title strategy a try as well.

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

Similar Threads

  1. Chart grouping in a report
    By james28 in forum Reports
    Replies: 8
    Last Post: 03-01-2014, 10:33 PM
  2. Pivot Chart in Report
    By JayRab in forum Reports
    Replies: 2
    Last Post: 02-14-2014, 04:02 PM
  3. Replies: 10
    Last Post: 08-29-2013, 09:21 PM
  4. Chart is not showing up on the report.
    By Guntar in forum Programming
    Replies: 1
    Last Post: 12-19-2012, 03:11 PM
  5. Adding a chart to a report
    By Bigmix in forum Reports
    Replies: 7
    Last Post: 02-14-2012, 08:47 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