Creating a Graph/Chart on a Report in VBA


Question

I just want to create a graph on a report within a module (using VBA) at run-time. Any suggestions on how to carry out this task or if anyone knows where I can get my hands on some good source code relating to this then that would be great.

Answer

From: Shamil Salakhetdinov <shamil@marta.darts.spb.ru>
To: ACCESS-L <ACCESS-L@PEACH.EASE.LSOFT.COM>
Subject: Re: Create a Graph/Chart on a Report in VBA!
Date: 28 May 1999 1:51

John,

Here is the trick based on wztool80.wztool_mod.cw_ErrCreateChart function:

Dim rpt As Access.Report
Dim ctlObjFrame As Access.ObjectFrame
Dim cw_rsTemplates As DAO.Recordset

Set rpt = CreateReport
Set ctlObjFrame = CreateReportControl(rpt.Name, _
      acObjectFrame, , "", "", 100, 100)
Set cw_rsTemplates = CodeDb().OpenRecordset( _
      "cw_tblChartTemplates", dbOpenDynaset)
cw_rsTemplates.MoveFirst
' Set OleData property to template graph from OLE field
ctlObjFrame.OleData = cw_rsTemplates!ChartObject
DoCmd.Restore

Get wztool80 sources and dig into them...

HTH,
Shamil


HOME    TOPICS

Copyright © 1999 by Shamil Salakhetdinov.
All rights reserved. Terms of use.

Last updated: October 10, 2006

Published also here at 4TOPS: Creating a Graph/Chart on a Report in VBA