Crystal Report using Adobe Reader to view under VB6 development

Hi all,

I am using Visual Basic 6. And my report is using Crystal Report 8.5 to develope. I am doing the Windows application using VB6.
On my windows application, when I click on the preview button, I will use the below coding to export my crystal report to PDF file, and use Adobe Reader to open the PDF file.
          Coding:
                    Private Sub PrintReport()
                         Dim crReport As New cr_po

                         crReport.ExportOptions.ApplicationFileName = "C:\Purchase_Order.pdf"
                         crReport.ExportOptions.DestinationType = crEDTApplication
                         crReport.ExportOptions.DiskFileName = "C:\Purchase_Order.pdf"
                         crReport.ExportOptions.PDFExportAllPages = True
                         crReport.ExportOptions.FormatType = crEFTPortableDocFormat
                         crReport.Export False
                    End Sub

When the report being view in the adobe reader. Then I go to my windows application and click the "Preview" button again, it will having an error by saying that
                                          " Run-time error '-2147206452 (80043acc)' "
                                          The file is use by another application.

I know this is because of the PDF file is being open, my another PDF file is creating and using the same file name. I just want to know is there any other way to view the Crystal Report file in PDF?

Thanks & Best regards.
runbirdAsked:
Who is Participating?
 
mlmccCommented:
What if you modified the filename to include a global variable

Something like this
FileNameModifier = FileNameModifier + 1
crReport.ExportOptions.DiskFileName = "C:\Purchase_Order_" & CStr(FileNameModifier,0) & ".pdf"

mlmcc
0
 
mlmccCommented:
What happens if you comment out or delete this line
crReport.ExportOptions.DiskFileName = "C:\Purchase_Order.pdf"


mlmcc
0
 
runbirdAuthor Commented:
Even though I comment out this line >> crReport.ExportOptions.DiskFileName = "C:\Purchase_Order.pdf"
I am still getting the same error. Because when one pdf file is browsing, another pdf file will not be able to export with the same file name.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.