Adding a Chart to a Report

JanH

New member
Local time
Today, 08:40
Joined
Apr 2, 2013
Messages
3
I have a popup form that prompts for a value and has a button defined with an OnClick,OpenReport with a WHERE clause. The value the user enters is placed in the WHERE clause.

The report is generated using a Query and the WHERE clause.
I was very surprised -- it works!

Now I'd like to add a chart to the report that represents the information on the report. How can I do this without calling the query again? Can I somehow reference the information that's in the report?

Thank you!
 
What I've done before in this case is create the chart on a hidden form, and saved the chart image to disk. Then open your report and load the saved chart image into an image control in the report.

Here's a blog post about it.

Here's sample code . . .
Code:
    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
 

Users who are viewing this thread

Back
Top Bottom