Monday, January 30, 2012

How To: Put a Pivot Chart in an MS Access Report

When you open an Access.Form in PivotChart view you can use the form's Chartspace.ExportPicture() method to write that chart's image to disk. Then your report can programmatically load that image into an Image control. 
Consider this Report_Open() event handler ...
Private Sub Report_Open(Cancel As Integer)
   Const FN As String = "frmYourChart"
   Dim filespec As String
   filespec = CurrentProject.path & "\ImageName.gif"
  
   DoCmd.OpenForm FN, acFormPivotChart, , , , acHidden
   Forms(FN).ChartSpace.ExportPicture filespec, "gif", 950, 625
   DoCmd.Close acForm, FN
   Me.Image0.Picture = filespec

End Sub
MSDN ExportPicture() Reference

No comments:

Post a Comment