Solved

Adding data to an msgraph 8.0 object

Posted on 2007-12-05
14
259 Views
Last Modified: 2016-08-29
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"

Open in new window

0
Comment
Question by:pancho_alvarez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
14 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 20417319
pancho_alvarez,

I posted some advice in your previous post.

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
 

Author Comment

by:pancho_alvarez
ID: 20418943
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"

Open in new window

0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 20421598
hmmm.

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:pancho_alvarez
ID: 20429324
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
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 20430728
pancho_alvarez,

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
0
 

Author Comment

by:pancho_alvarez
ID: 20430856
Hello Jeff,
                  Here's the sample data, sorry about the screeshot but I don't know how to paste it here.

PERIOD         ISOLATED      MULTIPLE      SYNDROMES      DOWN SYNDROME
1980-85         17,10               2,64                         2,44                   1,004
1986-05          10,069             2,48                           1,89                    0,85
2006             7,85                 2,36                       1,35                     0,71

Best regards



0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 20431442
To *POST* a screenshot, follow these steps:

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
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 20446610
pancho_alvarez,

Here is the same graph, (In a Report) created *without* VBA code.
https://filedb.experts-exchange.com/incoming/ee-stuff/6092-Access--EE-Q-23003107--Manual-C.zip

It took me less than 30 seconds!
:)

Are you sure you still want to use VBA code?
:O

JeffCoachman
0
 

Author Comment

by:pancho_alvarez
ID: 20449110
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.

Cheers
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 20451425
OK,

I'll be waiting...
:)

JeffCoachman
0
 

Author Comment

by:pancho_alvarez
ID: 20485677
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
 

Author Closing Comment

by:pancho_alvarez
ID: 31412857
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.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 20485786
OK,
Happy Holidays!

JeffCoachman
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question