Results 1 to 10 of 10
  1. #1
    chrtophe is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Nov 2013
    Posts
    5

    modify ms-chart graphic legend

    Hello,

    I'm trying to change the text legend in a Graphic.

    Here's my code :


    Code:
    Dim vlChart As Graph.Chart
    Set vlChart = Me.Graphique2.Object.Application.Chart
    Dim vlegend As Legend
    Set vlegend = vlChart.Legend
    
    MsgBox "before modification " + vlChart.Application.DataSheet.Range("A0").Value
    vlChart.Application.DataSheet.Range("A0").Value = "test"
    MsgBox "after modification " + vlChart.Application.DataSheet.Range("A0").Value
    
    vlChart.Refresh
    Me.Requery
    Me.Refresh
    The refreshes don't work.

    The MsgBox return the good result after modification, but the graph display keeps the original legend title.

    I tried with Legend.LegendEntries(0) without result i don't if it's possible.

    Thanks for your help and sorry for my english level, i'm french.

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    did you try sticking

    Code:
    vlchart.application.update
    after you set the value?

  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,929
    You are doing this in Excel?

    I have code behind Access form that modifies properties of graph. Doesn't require Refresh or Update. However, Legend is not one I've tried. Most of my graphs are designed without a legend anyway.
    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
    chrtophe is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Nov 2013
    Posts
    5
    vlchart.application.update makes no change.
    June, i'm making it under Access. I'have read this method is ok but i'm not sure of the source.
    I don't undrerstand
    Is there another method than DataSheet.Range to access the legend ?
    Thanks for your answers

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You are using code that applies to spreadsheet and has nothing to do with Access structure. So exactly where is this graph?
    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.

  6. #6
    chrtophe is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Nov 2013
    Posts
    5
    This graph is in a Access Form, his contents come from an access query. this query is calculated from others querys ( in case of link with my problem ).
    I'm ok with a other way, with .Legend for example but i did'nt arrived. I saw samples to modify font, color, etc... but not text.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    At first, that code looked like it referenced a spreadsheet but now I see it's actually referencing the chart datasheet. I have never done code to do that.

    Not sure what you want. The legend is based on data. Why would you want to change the legend labels?
    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.

  8. #8
    chrtophe is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Nov 2013
    Posts
    5
    I want to change the legend label refering to the year, my graphics curses represents data of the current year and data of the last year. I want to display the legend text containing the year without to have to change legend next year.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The legend labels are based on series names generated by the chart RowSource query. I don't think they can be changed programmatically. Restructure the query.

    Perhaps if you provided examples by images or attached db, could analyse and find a solution.
    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.

  10. #10
    chrtophe is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Nov 2013
    Posts
    5
    I think i have a solution ( i'have not tested yet ).
    Il will retrieve the ms-chart rowsource, change title with As in the SQL request, and change the rowsource. i will tell you if it's ok.

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

Similar Threads

  1. Chart legend
    By afshin in forum Queries
    Replies: 3
    Last Post: 10-25-2012, 02:59 AM
  2. some problem in showing chart legend
    By afshin in forum Queries
    Replies: 5
    Last Post: 09-16-2012, 10:03 AM
  3. Replies: 4
    Last Post: 07-29-2012, 04:38 PM
  4. Replies: 4
    Last Post: 03-04-2012, 08:59 PM
  5. Chart legend appears as date
    By Vronsky in forum Programming
    Replies: 0
    Last Post: 06-09-2011, 05:20 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