Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Chart Title in A Form

Status
Not open for further replies.

splint1906

Technical User
Jul 19, 2004
27
US
I have embedded a chart on a form. I am having difficulty with its Title. I want the Chart title to say:
"Trailing 12 months Average Unit Price for Part # XXXX". The user selects the Part # on another tab on my form.

How do I get the actual part number to show up in the title? I have tried ""Trailing 12 months Average Unit Price for Part # " &[Part#] but that does not work.
 
How are ya splint1906 . . . . .

Try This (you substitute names in [purple]purple[/purple]):
Code:
[blue]   Dim Chart As Object, Txt As String
   
   Set Chart = Me![purple][b]YourChartControlName[/b][/purple]
   Txt = "Trailing 12 months Average Unit Price for Part # "
   
   Chart.ChartTitle.Text = Txt & Me![Part#]
   Set Chart = Nothing[/blue]

Calvin.gif
See Ya! . . . . . .
 
I tried and got this error message:

Unable to set the Text Property of ChartTitle class

not sure what that means?
 
splint1906 . . . . .

First, lets make sure of the name you substituted in [purple]purple[/purple].

Open the form in design view. Right-Click the chart and select [blue]Properties[/blue]. Select the [blue]Other Tab[/blue]. At the top, whats in the [blue]Name Property[/blue], is what you should've used.

If you used that name, skip to the next paragraph, otherwise, [blue]make it so[/blue] and let me know!

Since you used the proper name, a Reference Library has to be set. So open any VBE Code Window; select Tools - References. Scroll down thru the list, your looking for [purple]Microsoft Graph X.X Object Library[/purple]. Check-Off the highest version available and try again. Let me know the results . . . . .

Calvin.gif
See Ya! . . . . . .
 
Sorry for the late response. I did use the correct chart title. But, I did not set the reference library. So , I set it to MS Graph 10.0 Graph Library.
But, when I tried it, I still get this message:
"Run-time error '1004'
Unable to set the Text property of the ChartTitle property"

Apparently, it is not recognizing the ChartTitle property...maybe?
 
splint1906 . . . . . .

I've done this a number of times in the past, and setup a simulation per this thread. [blue]No Problemo[/blue] on results, works fine for me.

Hmmmmmm . . . . . what version Access ya using?

Meantime I'm researching posibilities . . . . .

Calvin.gif
See Ya! . . . . . .
 
We run Access 2000 here.

Here is the code that I have:
Private Sub AvgPriceGraph_GotFocus()
Dim Chart As Object, Txt As String

Set Chart = Me!AvgPriceGraph
Txt = "Trailing 12 months Average Unit Price for Part # "

Chart.ChartTitle.Text = Txt & Me![Part#]
Set Chart = Nothing
Refresh
End Sub
 
splint1906 . . . . .

Interesting, [blue]Access 2000[/blue] (SP3) here also! . . . .

Try modified code:
Code:
[blue]   Dim Chart As Graph, Txt As String
   
   Set Chart = Me!AvgPriceGraph
   Txt = "Trailing 12 months Average Unit Price for Part # "

   With Chart
      .HasTitle = True
      .ChartTitle.Text = Txt & Me![Part#]
      .Refresh
   End With

   Set Chart = Nothing

End Sub[/blue]
If that doesn't work, try changing the reference [blue]MS Graph 10.0 Graph Library[/blue] to [blue]9.0[/blue].

This concerns me as [blue]10.0[/blue] is not listed in my references and I'm up to date with service paks (SP3). When you check the reference, click the line and look at the bottom for the path/filename. When you post back, let me know the filname for 10.0.

Calvin.gif
See Ya! . . . . . .
 
I've tried several different versions of the above code and it sill does not work. I keep getting the error "Run-time error '1004'
Unable to set the Text property of the ChartTitle property"

It is as if it does not recognize the ChartTitle property.

The filename is C:\Program Files\Microsoft Office\Office10\GRAPH.EXE
 
splint1906 . . . . .

Although were both using Access 2000, I'm at somewhat of a loss as we have [blue]two different libraries[/blue] for Microsoft Graph. Namely [blue]Graph.exe[/blue] (yours) and [blue]Graph9.olb[/blue] (mine). The really bad part is that [blue]their not compatible![/blue] Apparently [blue]Objectivity[/blue] is not quite the same.

I checked my installation & CD. No [blue]Graph.exe[/blue] exist. I did find installed library files for all the major components of Office, all in [blue]*.olb[/blue]! So I could'nt convert to Graph10.

I'd tell ya to look for [blue]Graph9.olb[/blue] but apparently you have a different installation for Microsoft Graph. . . . wierd!

Thes best I can offer at this time is to open any VBE window, click on the [blue]Object Browser[/blue] toolbar button and check out the graph library. All Objects, properties & methods will be listed. You can click a property or method then help to read all about it.

When my research turns up anything I'll let ya know . . . .

Calvin.gif
See Ya! . . . . . .
 
AceMan,

Thanks for all of your help. I went to the Object Browser and I found the ChartTitle property under the graph library. I read the help and it suggested to use this code:
With Me.AvgPriceGraph
.HasTitle = True
.chartitle.Text = "Trailing 12 months Average Unit Price for Part # " & Me![Part#]
End With

But, when I try it I still get the same error:
'Unable to set the HasTitle property of the chart class'

I am no VB expert so I'm not sure what to do from that perspective. But, I think it is a problem with version of Access I am using here at work. There may be some other references I need and/or don't have.

These are the References I currently have:
Visual Basic for Applications
Microsoft Access 10.0 Object Library
OLE Automation
Microsoft ActiveX Data Objects 2.7 Library
Microsoft ActiveX Data Objects Recordset 2.7 Library
Microsoft Graph 10.0 Object Library
 
splint1906 . . . .

Sorryto get back so late.

The link below shows marriages between [blue]Access 2000/Graph9.olb[/blue] & [blue]Access 2002/Graph.exe[/blue]. I found quite a few other links to support this.

splint1906 said:
[blue]We run Access 2000 here.[/blue]
So . . . . . definitely a Library conflict here. How ya got the wrong library installed (according to the link) is beyond me.

Are you sure you have Access 2000 and not 2002?

Do a search for [blue]Graph[/blue] on your harddrive and post all the files in any office directory. Then do the same for your installation CD. If they differ, post those as well . . . . .

If your installation CD shows [blue]Graph9.*[/blue], I would uninstall/reinstall.

Calvin.gif
See Ya! . . . . . .
 
It's definitely Access 2000. And, it's an installation here at work. I don't have the install cd. My Access DB is being accessed by users in a varity of places so fixing it just on my pc and not everyone else's is not going to work.

I did a search on my pc and I only found Graph10 files. I read the page you linked from MS support and that went righ over my head.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top