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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Viewer Problems

Status
Not open for further replies.

Theadmans

Programmer
Oct 23, 2006
35
GB
Hi,

I posted this in the Crystal Integration Forum yesterday but got no replies - so I am hoping that some kind person may see it here instead! Here goes:-

I am fairly new to Crystal and am trying to covert our VB 6.0 Application to load Crystal Reports from .Rpt files instead of Crystal Designer (DSR/DSX) Files. We use Crystal 8.0

I have cobbled together the following code which works on the first run of the report. However, if I try to run it another Report (whilst the first report is still on the screen) then I get "CRViewer Memory is Full". Here is my code :-


Unload FrmReport
Fxload FrmReport, True

Dim crxApp As New CRAXDRT.Application
Dim crxRpt As CRAXDRT.Report
Set crxRpt = crxApp.OpenReport(App.Path & "\Reports\MyReport.rpt")

Screen.MousePointer = vbHourglass

On Error Resume Next

crxRpt.Database.Tables(1).SetLogOnInfo "ServerOrDNSName", "DBName", "UserId", "Password"

FrmReport.CRViewer.ReportSource = crxRpt
FrmReport.CRViewer.ViewReport
Do While FrmReport.CRViewer.IsBusy
DoEvents
Loop

Set crxRpt = Nothing

On Error GoTo 0

I guess I am doing something wrong in not closing the CRViewer. How can I close the CRViewer when the next report is requested or is there a different problem with my code?

Has anybody got any ideas it is driving me mad!!
 
Try creating a new instance of your 'FrmReport' for each report rather than using the actual form itself.

Set the CRViewer.reportSource in the forms initalize event, passing it the CRAXDRT.Report object.


zemp
 
Thanks for your reply ! When you say create a new instance of FrmReport how would I do this with my above code? Sorry if this is a silly question but I am still a novice with VB.
 
Create a form object variable
Code:
Dim frmP As Form    '// Form for previewing report.
Then set it to a new form. Here is where I pass the report as an object. 'frmViewer' is my form that holds the viewer. you call it frmreport.
Code:
         '// Previews the report on the screen.
         Set frmPV = New frmViewer
         frmPV.Initialize CR_Report, "Report Title"
Then in the initalize event
Code:
Public Sub Initialize(pReport As CRAXDRT.Report, pTitle As String)
'// Initialize the form.
   With caxrViewer
      .ReportSource = pReport
      .ViewReport
      .Zoom 100
   End With
   Me.Caption = pTitle
   Me.Show
End Sub




zemp
 
Thanks Zemp - I'll give that a try soon. Although at the momemt my PC has died - got the Engineer on call!
 
Sorry I missed a letter in the declaration...it should read
Code:
Dim frmPV As Form    '// Form for previewing report.

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top