exporting to PDF

vb.net , crystal report , exporting , PDF Saint Louis, United States
  • 11 years ago

    I have a database app where on a button click, I export the current record to crystal report which in turns converts it to a PDF file. Upon application startup, I export one record into PDF just fine but when I move ahead to the next record and I click the export button, the new PDF file that was exported is now blank. If I restart the app, I can then export the one record again but any subsequent record will export to PDF as a blank PDF file.

    To sum up: I can export one record once using the below code snippet but when I try it for a second time on another record, I get a blank PDF file (only the crystal report formatting is in the PDF).

    [code] cryRpt.RecordSelectionFormula = "{PRREQUESTS.ID} = " & lblRequestNum.Text [/code]

    *this above line of code does what it should but it doesn't do it everytime....only the first time.

    Here is all the code for the button click event for the export:

    [code] Private Sub btnSubmitNewReq_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmitNewReq.Click

        cryRpt.Load("H:\programs\PR_Requests\PR_Requests\rptPRRequests.rpt")
    
        Try
    
            cryRpt.RecordSelectionFormula = "{PRREQUESTS.ID} = " & lblRequestNum.Text
    
            Dim CrExportOptions As ExportOptions
            Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
            Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()
            CrDiskFileDestinationOptions.DiskFileName = "H:\PR_Request_" & lblRequestNum.Text & ".pdf"
            CrExportOptions = cryRpt.ExportOptions
            With CrExportOptions
                .ExportDestinationType = ExportDestinationType.DiskFile
                .ExportFormatType = ExportFormatType.PortableDocFormat
                .DestinationOptions = CrDiskFileDestinationOptions
                .FormatOptions = CrFormatTypeOptions
            End With
            cryRpt.Export()
        Catch ex As System.Exception
            MsgBox(ex.ToString)
        End Try
    

    End Sub [/code]

    Thanks for any help!!! Jason

  • 11 years ago

    got it figured out....

    at the end of the code, I needed this:

    [code] cryRpt.close() [/code]

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Walking on water and developing software from a specification are easy if both are frozen.” - Edward V Berard