1 Replies - 1462 Views - Last Post: 29 June 2013 - 09:16 PM Rate Topic: -----

#1 tendaimare  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 170
  • Joined: 04-November 10

Disposing and intializing a crystalreportviewer object in vb6

Posted 25 June 2013 - 12:57 AM

I am using Crystal reports XI and I am using this code to print reports after a transaction. This code works fine but the Problem comes when I attempt a second transaction, I get the error "Method ReportSource of object ICrystalReportViewer11 failed". However If i do a transaction and print the report and close the form after that and then come back into the form to do the second transaction the code works fine. I am convinced that the solution is that I need to "dispose" the reportviewer and "initialise" it when I need to use it but I just need some guidance on how to do this. Any help.


Dim app As New CRAXDRT.Application
Dim rpt As New CRAXDRT.Report
Dim tbl As CRAXDRT.DatabaseTable
Set rpt = app.OpenReport("C:\SOS3000\NewReports\DNOPS01.rpt")
rpt.DiscardSavedData
For Each tbl In rpt.Database.Tables
tbl.ConnectionProperties.DeleteAll
tbl.ConnectionProperties.Add "Provider", "MSDASQL"
tbl.ConnectionProperties.Add "Data Source", "MS ACCESS DATABASE"
tbl.ConnectionProperties.Add "User Id", "Admin"
tbl.ConnectionProperties.Add "Password", "1234"
tbl.ConnectionProperties.Add "Initial Catalog", "C:\SOS3000\SOS3000S.accdb"
Next tbl
CRViewer1.ReportSource = rpt
rpt.PrintOut False, 1

Set app = Nothing
Set rpt = Nothing
Set tbl = Nothing




Is This A Good Question/Topic? 0
  • +

Replies To: Disposing and intializing a crystalreportviewer object in vb6

#2 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Disposing and intializing a crystalreportviewer object in vb6

Posted 29 June 2013 - 09:16 PM

Set rpt = New CRAXDRT.Report should dispose of the object and create a new one.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1