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 is not showing report

Status
Not open for further replies.

blocktl

Programmer
Jun 18, 2003
14
US
This is my code:

Dim crxApp As New CRAXDRT.Application
Dim crxRpt As CRAXDRT.Report

' Open the report
Set crxRpt = crxApp.OpenReport(App.Path & "\PrtPicTkt.rpt")

' Clear any saved data to force the report to read from the db
crxRpt.DiscardSavedData

' Set the connection for the report.
crxRpt.Database.Tables (1).SetLogOnInfo "Macola02", "Macola02", "administrator", "password"

' Set up the report source
frmUserInput.CRViewer1.ReportSource = crxRpt
'frmUserInput.CrystalReport1.ReportFileName = App.Path & "\PrtPicTkt.rpt"

Do ' more than one report per run

' Create itemSelect

' Set up selection formula
' frmUserInput.CrystalReport1.SelectionFormula = itemSelect
crxRpt.RecordSelectionFormula = itemSelect

' View report
frmUserInput.CRViewer1.ViewReport
' frmUserInput.CrystalReport1.Action = 1

Loop

When I execute this code it does not bring up the viewer. If I uncomment the three CrystalReport1 statements , then I get the viewer but it is not persistent. It lasts a second and then the next report is viewed without waiting for a response from the first view.

Can anyone tell me what's going wrong?
 
thanks virdru that's exactly what i want. My code now is:

Dim crxApp As New CRAXDRT.Application
Dim crxRpt As CRAXDRT.Report
'Declare a ReportSourceRouter object
Dim MultiReport As New CRVIEWERLibCtl.ReportSourceRouter


' Open the report
Set crxRpt = crxApp.OpenReport(App.Path & "\PrtPicTkt.rpt")

' Clear any saved data to force the report to read from the db
crxRpt.DiscardSavedData

' Set the connection for the report.
crxRpt.Database.Tables(1).SetLogOnInfo "Macola02", "Macola02", "administrator", "odyssey"

Do ' more than one report per run

' Create itemSelect

' Set up selection formula
crxRpt.RecordSelectionFormula = itemSelect
MultiReport.AddReport crxRpt

Loop

'Set the ReportSource of the Crystal Report Smart Viewer to the
'ReportSourceRouter object
CRViewer1.ReportSource = MultiReport
CRViewer1.ViewReport

However when I reach the statement setting the report source, I get an error "object required". Any ideas?
 
What version of CR do you have? I remember not getting it to work in (I think) CR 8.5 or CR 9, but I'm using it in a CR 10 integrated application.

-dave
 
BTW, if you send the same report object to the ReportSourceRouter "N" number of times in your loop, the end result would be "N" copies of the last version (whatever you're doing differently with each pass through the loop).

A more correct way of using the router within a loop would be to recreate the Report object each time through the loop:
Code:
'Report created using the Xtreme database's Customer table
Dim crxRouter As New CrystalActiveXReportViewerLib10Ctl.ReportSourceRouter
Dim crxApp As New CRAXDRT.Application
Dim crxRpt As CRAXDRT.Report

For i = 1 To 3
    Set crxRpt = crxApp.OpenReport("c:\tst.rpt")
    crxRpt.DiscardSavedData
    crxRpt.ReportTitle = "Report Instance #" & CStr(i)
    crxRpt.RecordSelectionFormula = "{Customer.Customer ID} = " & CStr(i)
    crxRouter.AddReport crxRpt
Next i
CRViewer1.ReportSource = crxRouter
CRViewer1.ViewReport
The end result of the above is: I've got a single viewer; the Group Tree shows the Title of each report (Report Instance #1, Report Instance #2, etc); and each report has a single record, matching the criteria I'd specified in each RecordSelectionFormula.

-dave
 
thanks Vidru, but the viewreport statement is still not doing anything. The code immediately moves to the next statement. no errors, no viewer, no nothing! I appreciate your help
 
Can you run a single report (without any looping) and see it in your Viewer?

And please post your version. It doesn't do me any good to test unless it's with the same version you're using.

-dave
 
I can see one report at a time in the viewer. I don't know the name of the viewer dll. I'm running crystal 8.5 on a windows 2000 machine.
 
The .dll is crviewer.dll. The default path for it is:
C:\Program Files\Seagate Software\Viewers\ActiveXViewer

The version of the CR 8.5 crviewer.dll on my machine (with which the router works fine) is 8.6.1.758. It could be that you need to download a hotfix and/or service pack to get it working.

-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top