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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help: Code; Graphs

Status
Not open for further replies.

Walshie1987

Technical User
Oct 5, 2006
100
Hi I have a bar chart (MyGraph) and a button (MyButton) when I click "MyButton" I want "MyGraph" to change to a pie chart automatically, so i have entered the following code:

Sub MyButton_Click()
Dim GraphObj As Object

Set GraphObj = Me![MyGraph].Object.Application.Chart
GraphObj.Type = xL3DPie
End Sub

but get:

"Run-Time error '1004'

unable to set the type property of the chart class

any ideas?
 
I made a quick chart in access 07 and your code seems to work for me.

ck1999
 
How are ya Walshie1987 . . .

You may need to refresh the object!
Code:
[blue]   GraphObj.Refresh[/blue]


Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Could some try the above code on Access 2003 please. Doesn't want to work for me at all!

Cheers
 
Hi Walshie1987,

Im guessing you took that code from the below link:


I think what you haven't done is step 9, where you have to add the reference for the graph object. Go to Tools->References on the Visual Basic Editor, and make sure that "Microsoft Graph 11.0 Object Library" is ticked (it says 9.0 on the link, but thats for Access 2000, whereas for Access 2003 which your, and me, using it is 11.0).

That should work, works for me anyway and I followed those steps on the link and it works perfectly.

Andrew
 
I also just tried this on one of my own databases, so using a different table/query etc, and it works. Note that if you want to do something like this on a different database, you will have to tick the Graph 11 Object Library on that database aswell, in the same way I described above.

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top