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!

Pass parameter to Crsytal report 1

Status
Not open for further replies.

richl13

Programmer
May 1, 2007
16
US
I have an app that opens a crystal report, sets the login info, passes the parameter, then exports the report. Below is part of the code I am using. I need to run this report multiple times with new parameter values. How can this be accomplished without doing OpenReport everytime?

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

Sub RunReport()
Set Report = crxApp.OpenReport("test.rpt",1)

'''Here I set the login

Report.ParameterFields(1).AddCurrentValue (ldr_id)

With Report.ExportOptions
.DiskFileName = slocation
.FormatType = crEFTPortableDocFormat
.PDFExportAllPages = True
.DestinationType = crEDTDiskFile
End With
Report.Export (False)

Set Report = Nothing
Set crxApplication = Nothing
End sub
 
Why don't you want to run OpenReport once for each .rpt file?
 
I do want to run it just once. I have 1 rpt file and this report accepts a doctor id. I have about 50 ids that I need to run this report with. Each one of these reports needs to be exported to a pdf file. Is it possible to pass the parameters to the report without doing OpenReport everytime?
 
<I do want to run it just once.

Why?

<Is it possible to pass the parameters to the report without doing OpenReport everytime?

Why do you need to do that?
 
Opening and closing the report everytime I want to change the parameter seems inefficient.
 
I don't believe there's any other way to do it. Question though; can you pass all 50 ids at once?
Assuming you have page break after your group on the report then you will generate a single report with 50 pages then export 1 single pdf. Will work if you're going to print & send, not if you have to send individually.

Patrick
 
Unfortunately, these need to be separate pdfs. It is a physician report that accepts physician ids.
 
Forgot to add that these are currently emailed to the physicians, but next month they will be accessing a portal to view their individual report.
 
Hang on .... Once you have your report object can't you loop through your IDs and refresh the report??

Patrick
 
Though maybe Report.ReadRecords will do the same thing ?? Sorry can't experiment where I am now to give you a definite answer.

Patrick
 
I got it to work. All I did was add the following before I add the parameters.

Report.ParameterFields(1).ClearCurrentValueAndRange

Thanks guys for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top