I use a form to create a pivotchart much like how it is explained in the Microsoft help file:
I created a blank pivotchart form "frmGraph" that I manipulate with OWC10 coding. "frmGraph" has no fields or recordsource. I define these properties in my main form, then the manipulated "frmGraph" is displayed in a subform ("fsubGraph") with all the data charted.
I would like to put this manipulated "frmGraph" into a report exactly as it appears in my subform then export the report as a Snapshot. I built a report with a blank subreport for the graph to be displayed in. Here's the code so far:
Main Form command button to export the graph as a snapshot:
Coding in Report Open Sub Routine:
The problem is the graph is just exporting blank with no data. Is there a way I can save the manipulated pivotchart only? I would rather not try and save the entire form because it contains a lot of data and takes a few seconds to save. Or is there a way to create a temporary form based on the manipulated pivotchart, then use that in the report to be exported as a snapshot?
Thanks for any help!
I created a blank pivotchart form "frmGraph" that I manipulate with OWC10 coding. "frmGraph" has no fields or recordsource. I define these properties in my main form, then the manipulated "frmGraph" is displayed in a subform ("fsubGraph") with all the data charted.
I would like to put this manipulated "frmGraph" into a report exactly as it appears in my subform then export the report as a Snapshot. I built a report with a blank subreport for the graph to be displayed in. Here's the code so far:
Main Form command button to export the graph as a snapshot:
Code:
Private Sub cmdViewReport_Click()
On Error GoTo Err_Handler
'Define charspace variable
Dim objChartspace As OWC10.ChartSpace
Set objChartspace = Me.fsubGraph.Form.ChartSpace
'These variables are declared
'globally in the "graph" module
strReportTitle = Left(objChartspace.Charts(0).Title.Caption, _
InStr(objChartspace.Charts(0).Title.Caption, "(") - 1)
strChartSource = Me.fsubGraph.SourceObject
'Now we must determine the username of
'the person that is logged into
'the computer in order to save the image
'to the correct "Desktop" address.
'This line of code calls the function above.
Dim strUser As String
strUser = fWin2KUserName
'Specify file name
Dim strSnpFileName As String
strSnpFileName = Me.cboChooseChart.Column(1) & _
"_" & Format(Now, "mm-dd-yyyy")
'Export Report as Snapshot
DoCmd.OutputTo acOutputReport, "Charts Report", _
"Snapshot Format", _
"C:\Documents and Settings\" & strUser & "\Desktop\" & strSnpFileName & ".snp", _
True, , False
'Notify User of what happened
MsgBox "A Report has been created and saved on the" & _
" computer's Desktop as the file: " & strSnpFileName & _
". You may print the report from the Snapshot Viewer or" & _
" use the saved file as an e-mail attachment.", _
vbOKOnly Or vbInformation, _
"Report Exported Successfully!"
Exit_Handler:
Exit Sub
Err_Handler:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Exit_Handler
End Sub
Coding in Report Open Sub Routine:
Code:
Private Sub Report_Open(Cancel As Integer)
On Error GoTo Report_Open_Err
'Title Labels:
Me.lblTitle.Caption = strReportTitle
'Must add "Form." to beginning of
'string expression to comply with
'Access Report Formating of
'Source Objects Rules
Me.rsubChart.SourceObject = strChartSource
Report_Open_Exit:
Exit Sub
Report_Open_Err:
MsgBox "Error " & Err.Number & " - " & Err.Description
Resume Report_Open_Exit
End Sub
The problem is the graph is just exporting blank with no data. Is there a way I can save the manipulated pivotchart only? I would rather not try and save the entire form because it contains a lot of data and takes a few seconds to save. Or is there a way to create a temporary form based on the manipulated pivotchart, then use that in the report to be exported as a snapshot?
Thanks for any help!