Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pivotchart Form to Report Problems

Status
Not open for further replies.

grgimpy

Programmer
Nov 1, 2006
124
US
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:

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!
 
I'll ask a simpler question to try and figure this out myself.

If I use the following code to create a form based on my pivotchart:

Code:
Dim frm As Access.Form
    Set frm = CreateForm(, "frmGraph")

it opens up a new form in design mode. How do I save this form and put it in form view?

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top