Access VBA Macro Programming

(Joao Candeias) #1
Populate your table with some data. Your table should now look like Figure 18-2.
You now need to create a template graph to be inserted into reports using VBA. Create a
new blank report by clicking Create on the Access menu and then clicking the Report Design
icon in the Reports Group of the ribbon. Click Design in the Access menu, and in the
Controls Group of the ribbon, drag the Chart icon (second row of controls with colored bars)
on to your report. Once positioned, drag the cursor to size the Chart control. The graph
should be assigned the name Graph0 when you look in the Properties window, but if it is
different, then change it to Graph0.
You will then be taken into the Chart Wizard. Select your table tblChart as the source and
select both the fields. Select a standard pie chart and then click Finish. The chart object will
now appear on your report.
Save the report with the namerptTemplate. Although the template has been pre-determined
as a pie chart and with a particular table as the source, all these properties can be changed
programmatically. However, in order to create a chart to use as a template, some source
information must be given.

232 Microsoft Access 2010 VBA Macro Programming


Figure 18-1 Entering a reference into the Microsoft Graph 12.0 Object Library
Free download pdf