I have a query in SQL and I want to add the data of the query to an MSGRAPH 8.0 object using code. So far, I have been able to select with code the type of chart as well as adding the the title of both AXIS and the main title of the chart. However, I still need to add the chart ROW LABELS and COLUMN LABELS of the chart, as well as adding the data of my query.
Thanks in advance
'type of chart MGO1.chartType = xlLine 'sets the legend of the chart on MGO1.HasLegend = True 'sets the main title of the chart MGO1.HasTitle = True MGO1.ChartTitle.Text = "ANOMALÍAS" 'Set the Y axis title MGO1.Axes(xlValue).HasTitle = True MGO1.Axes(xlValue).AxisTitle.Caption = "Porcentajes" 'sets the X axis title MGO1.Axes(xlCategory).HasTitle = True MGO1.Axes(xlCategory).AxisTitle.Caption = "Periodos"
I am still wondering why you need VBA code to create your charts?
Granted, creating charts in Access is not easy.
;)
But once you get the hang of it, it is pretty straightforward.
Your charts can/will look as good as any chart in Excel.
JeffCoachman
0
pancho_alvarezAuthor Commented:
Hello Jeff,
The reason I need to use VBA is that although my query returns the relevant data I need, using the wizard does not give me what I want. Hence, my bet is that programatically manipulating the microsoft graph object, as I've done with the mschart I can obtain the kind of chart I need for my application. So far, as you can see in the code snippet, I've managed to partially manipulate the chart. However, I still need to know how to add the row and column labels, as well as the data that will be charted.
'type of chart MGO1.chartType = xlLine 'sets the legend of the chart on MGO1.HasLegend = True 'sets the main title of the chart MGO1.HasTitle = True MGO1.ChartTitle.Text = "ANOMALES" 'Set the Y axis title MGO1.Axes(xlValue).HasTitle = True MGO1.Axes(xlValue).AxisTitle.Caption = "PERCENTAGE" 'sets the X axis title MGO1.Axes(xlCategory).HasTitle = True MGO1.Axes(xlCategory).AxisTitle.Caption = "PERIODS"
Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.
Can you post some sample data and a screen-shot of the corresponding chart?
I'm just curious if I can recreate the chart.
:)
JeffCoachman
0
pancho_alvarezAuthor Commented:
Hello Jeff,
I found the reason why I was not able to obtain the appropriate chart with the data of my query. The problem was that I was using the FORMAT(data,"#0.00") function and, somehow, the data was interpreted as a string of characters instead of numbers. I modified the query and obtained the results I wanted.
However, I sill would like to know how to progamatically manipulate the MSGRAPH ;-)
Thanks in advance
0
pancho_alvarezAuthor Commented:
Hello Jeff,
Here's the sample data, sorry about the screeshot but I don't know how to paste it here.
1. Open your Report to view your graph.
2. Zoom in so the graph fills the screen. (But does not go outside the screen)
3. Press the "Print Screen" (Prnt Scrn) key on your keyboard
4. Open MS Word or MS Wordpad
5. Click: Edit--> Paste
(The screenshot should now be visible in the Document
6. Close and save the document.
7. Use a program like Winzip and compress the document.
8. Go to: www.ee-stuff.com
9. Log in
10. Click the link to "Upload a new file"
11. Enter the question number: 23003107
12. Browes to where you saved the compressed file
13. Type in a comment
14. Click the "Upload" button
15. Right click the "Direct Link to your file" hyperlink address, and choose "Copy Shortcut"
16. Create another post to this Q and past in the hyperlink address, so I can see it.
If you need any help with this let me know
:)
Jeff
0
pancho_alvarezAuthor Commented:
Hello Jeff,
I posted the ZIP file with the chart as you requested. Here's the URL:
Hello Jeff,
I definitely would like to know how to manually modify the chart using VBA. However, if its too troublesome -as it seems to be- I will give the the points for beings so helpful in solving this dilemma.
Hello Jeff,
Since no one has answered my question and you were quite helpful with my problem, I'll give you the points ;-)
Cheers!
0
pancho_alvarezAuthor Commented:
Thanks for the help Jeff, I will keep resarching to see if I can programatically do the charts. Although with the appropiate query the assistant works well.
There is not that much out there. That's why I taught myself to create them manually.
Here is my favorite link on the subject, lots of info provided:
http://www.vb123.com/toolshed/99_graphs/msgraph1.htm
Here is another:
http://ourworld.compuserve.com/homepages/RHendricks/msgrppmc.htm
BTW,
Can you post that sample data and a screenshot of your graph,... I'm just curious...
:)
JeffCoachman