Change graph title with code (1 Viewer)

Pastor Del

New member
Local time
Today, 10:16
Joined
Nov 11, 2013
Messages
9
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
 

JHB

Have been here a while
Local time
Today, 19:16
Joined
Jun 17, 2012
Messages
7,732
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.
Why are you asking that again, can't you use the solution you got in this thread?
http://www.access-programmers.co.uk/forums/showthread.php?t=256668

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  Me.Graph17.Object.ChartTitle.Caption = "Team " & CStr(Me.Team)
End Sub
 

Pastor Del

New member
Local time
Today, 10:16
Joined
Nov 11, 2013
Messages
9
Sorry to cause such a stir. Next time I'll make note that I'm cross posting.

The reason I cross posted was that I'm not getting a reply that works. Don't remember the exact error message I got with the code above (I'm away from my computer) but I do remember that nothing beyond "Me.Graph17.Object." was recognized.
 

JHB

Have been here a while
Local time
Today, 19:16
Joined
Jun 17, 2012
Messages
7,732
Yes of cause, when you move the code to another report you've to replace the
"Graph17" with the name of your graph object in that report.
Code:
Me.TheNameOfYourGraph.Object
 

Pastor Del

New member
Local time
Today, 10:16
Joined
Nov 11, 2013
Messages
9
I used the name of my graph (Graph13) when I tried it. As I said, it didn't work. I saw something online last night about different libraries. I'm going to look into that. How can I know what libraries to use?

I'm on one or more of the following forums seeking answers to this graph issue.

Utter Access
Access World Forums
dB Forums
Access Forums
 

JHB

Have been here a while
Local time
Today, 19:16
Joined
Jun 17, 2012
Messages
7,732
I used the name of my graph (Graph13) when I tried it. As I said, it didn't work.
Sorry - I know it is working and you do also, because you wrote in this thread
http://www.access-programmers.co.uk/forums/showthread.php?t=256668
Post # 3,
This is great. The way I managed to do it required 10 charts because there are 10 teams that will be charted. One down side to my way is that I need to modify the report design if another team is added to the list. Yours is much better. Can you provide me with a step by step instruction of how to do this. Unfortunately I have very little experience with charts.
But ofcause you decide what solution you want to use.
Just for checking it I downloaded the database again and it still works.
 

Pastor Del

New member
Local time
Today, 10:16
Joined
Nov 11, 2013
Messages
9
You are confusing different questions I'm asking. One question is how to change the title of a graph with code. The other one boils down to making a graph that will do something close to what I did with the graphs I got help with late last year.

Question 1: The code suggested above gives an error when I try it - and yes I did use the name of my graph when I tried it.

Question 2: The graph I got help with last year works for 1 customer. Now my QA mgr also wants a report for all customers. I have not been able to figure out how to do it.

Can someone help me with one or both of these questions? The 1st question is in this thread. The 2nd question is on Utter Access with a topic title of Create Report. Thanks for any help.
 

Pastor Del

New member
Local time
Today, 10:16
Joined
Nov 11, 2013
Messages
9
I figured out the answer to my original question in this thread. JHB gave me good code in this thread but probably assumed I know which event to put it in. Unfortunately I didn't know. I'm posting the following on several forums because I've seen this question asked many times out there and even though replies give good code they are not telling which event to put it in.



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"

Hope this helps others
 

Users who are viewing this thread

Top Bottom