Results 1 to 7 of 7
  1. #1
    Pastor Del is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    6

    Change chart title with code

    Can anyone tell me how to change the Title of a graph with code. By title I mean the box on the graph that automatically displays the name of the table used to create the graph in the chart wizard. I've tried numerous bits of code found in different forums but they all failed.

    Access 2010


    OLE Class: Microsoft Graph Chart
    Class: MSGraph.Chart.8

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    I don't change chart title but do change the x and y axis titles.

    With Me.graphname
    'y axis title
    .Axes(xlValue, xlPrimary).AxisTitle.Text = "something"
    'x axis title
    .Axes(xlCategory, xlPrimary).AxisTitle.Text = "something"
    End With

    Did you try: http://msdn.microsoft.com/en-us/libr...ffice.11).aspx
    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.

  4. #4
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402
    From MSDN
    as shown above,
    With Worksheets("sheet1").ChartObjects(1).Chart
    .HasTitle = True
    .ChartTitle.Text = "February Sales"
    End With

  5. #5
    Pastor Del is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    6
    I figured out the answer to my original question in this thread. To change a graph title with VBA you put the following code in PageHeaderSection_Format or PageHeaderSection_Print event. Maybe other events too but I didn't pursue it that far - just know it won't work in open event, etc.


    Code:
    Me.MyGraphName.ChartTitle.Text = "New Title"

    I'm cross posting this in several other forums because I've seen this question asked many times. Even though the replies give good code they don't tell you which event to put it in.

    Trevor: I'm not sure about your code. I confess that I didn't try it because it looks like Excel (Worksheets). I'm self-taught in Access so maybe it works and I don't understand.

    June7: I tried your code in the open event and it gave me an error. Didn't try it again after I figured out which event to use but it looks like it would work.

    Thanks to those who give their time to help

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    The HasTitle and ChartTitle.Text lines should work with the Access graph object. Ignore the With Worksheet and use the With I show.

    I have code in the form Current event.
    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.

  7. #7
    Pastor Del is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    6
    thanks I'll give it a try

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

Similar Threads

  1. Edit chart title on report
    By dougie in forum Programming
    Replies: 0
    Last Post: 12-10-2012, 06:56 AM
  2. Cannot change column title
    By Ancient Dragon in forum Access
    Replies: 3
    Last Post: 11-12-2012, 08:44 PM
  3. Replies: 2
    Last Post: 05-26-2012, 01:08 PM
  4. Dynamic Chart Title in Report
    By Kirsti in forum Reports
    Replies: 10
    Last Post: 03-21-2012, 01:56 PM
  5. Chart Workspace Title
    By thestappa in forum Queries
    Replies: 0
    Last Post: 07-07-2010, 10:23 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