dbTalk Databases Forums  

Re: chart VBA tutorial

comp.database.ms-access comp.database.ms-access


Discuss Re: chart VBA tutorial in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bradley
 
Posts: n/a

Default Re: chart VBA tutorial - 09-01-2003 , 11:09 PM






"mahnovetsky" <mahnovetsky (AT) yahoo (DOT) com.au> wrote

Quote:
Does anybody know of any good tutorials on the net that can help me
use VBA to program chart. As I have to extract data from a table and
display to a chart which I can't do in a sql query. I have tried using
google to find a good tutorial site, but haven't found any. ....
I found little help on it but have taught myself a lot so I may be able to
help.. let me know what you need to do and I'll try to give you an example
or something.

Why can't you use a query as your datasource for the Chart?

I've written code to set the datasheet of the graph object.. the recordset
used is a Crosstab.

First I clear the datasheet...

MyGraph.Datasheet.Cells.ClearContents (note this doesn't work properly in
Access 97)

I go through the field names of my recordset (rs) and set the first row of
the datasheet (Y axis labels)...

row = 1
For col = 2 To rs.Fields.Count 'skip first column as this is my X axis
labels
MyGraph.DataSheet.Cells(row, col) = rs.Fields(col - 1).Name
End If
Next

Then I go through my recordset to write the data...

row = 2
rs.MoveFirst
Do Until rs.EOF
For col = 1 To FieldCount
'NOTE: do not assign recordset field values directly to the Graph
object
'Instead assign to variable first. Took me ages to find out why it
was crashing.
MyData = rs.Fields(col - 1)
MyGraph.Datasheet.Cells(row, col) = MyData
Next
rs.MoveNext
row = row + 1
Loop

Hope that makes some sense.

Also, do a search on the Microsoft site for the MSGraph VBA help files!
These helped a lot.
--
Bradley
Software Developer www.hrsystems.com.au
A Christian Response www.pastornet.net.au/reponse




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.