Populating data in MS Graph Chart by VBA (1 Viewer)

KeithWilliams

Registered User.
Local time
Today, 04:27
Joined
Feb 9, 2004
Messages
137
Hi,

I found the following article in the MS Knowledge Base:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/off2000/html/grobjdatasheet.asp

That is what I need to do in my Access 2000 form: populate the data in a Chart (MS Graph object) by VBA. I tried the following code:
Graph_Data.Application.DataSheet.Range("A1").Value = "E"
Graph_Data.Application.DataSheet.Range("B1").Value = "32"
but Access responds with "Compile Error: Method or data member not found", pointing to the Datasheet field.

The KB article says I need a reference to the chart. Is my reference not valid, or not from within MS Access? Graph_Data is the name of my Chart control on the form. I have included a reference to Microsoft Graph 9.0 Object Library in my Tools > References.

I would greatly appreciate any help.

Thanks,
Keith.
 
Local time
Yesterday, 23:27
Joined
Oct 6, 2004
Messages
15
Same problem

Hey Keith,
I've been having that same problem and I can't figure it out either. Maybe if we both whine about it someone will help us. The article that talks about referencing the chart just means you need to either dimension it at the top of the program (Dim Graph_Data as Graph) or use Me.Graph_Data.Application . That's not what the problem is I don't think. When you use the autofill code thingy in the VBA editor, "DataSheet" isn't listed as one of the options you can use in "Application", meaning the reference libraries we are using don't have "DataSheet" programmed into them. When I go to references, there is a big list of libraries to check off. I'm guessing it's in one of them, but I can't find it. Just out of curiosity, which version of Access are you running? I'm using 2002.
Tom
 
Last edited:

fpendino

Registered User.
Local time
Yesterday, 22:27
Joined
Jun 6, 2001
Messages
73
You will probably have to declare the graph as an object. The example that you posted seems to be declaring it as an object, calling it 'mychart'. I don't have the exact code on how to do this, but I will try to see what I can find. Hope this helps point you guys in the right direction.
 

KeithWilliams

Registered User.
Local time
Today, 04:27
Joined
Feb 9, 2004
Messages
137
Hi again,

I'm using Access 2000.

I tried:
Dim Graph_Object As Object

Graph_Object = Me.Graph_Data
but this produces a runtime error 91: "object variable or with block variable not set". I also tried data types Graph and Chart, to no avail.

I have developed an SQL query that does the job, but I am still interested in resolving this for future use.

Thanks,
Keith.
 
Local time
Yesterday, 23:27
Joined
Oct 6, 2004
Messages
15
yeah...

I just looked around and saw that they always declared everything as an object.

Dim Graph_Data as Object
Dim objDataSheet as Object

Set Graph_Data = Me!WhateverGraphName.Object
Set objDataSheet = Graph_Data.Application.DataSheet

.
.
.

objDataSheet.Range("A1").Value = 32

Oh well. At least it's solved now.
 

Users who are viewing this thread

Top Bottom