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

Passing Parameter to Reports - Failing

Status
Not open for further replies.

sdempsey

Programmer
Mar 23, 2005
36
0
0
GB
I am using Crystal Reports 10 and SQL Server 2000.

I have added the following code to a DTS package and is contained within an ActiveX script.

The code seems to work and a report is produced however it does not contain any database values from the tables.

The report has a number of different sub reports.

Set Conn = CreateObject("ADODB.Connection")
Set Comm = CreateObject("ADODB.Command")
Set Rcdset = CreateObject("ADODB.Recordset")


Conn.Open "Provider=SQLOLEDB.1;Initial Catalog=Backup_Database;App=Crystal Export;Data Source=(local)", "blank", "blank"
Comm.ActiveConnection = Conn

'holds the reports that are due to be printed
final = "normal_reports_last_generated"
Rcdset.Open final, Conn, adOpenStatic, , adCmdTable

While (NOT Rcdset.EOF )

currentpractice = Rcdset.Fields.Item(1)

--check and the right number is being added

Set App = CreateObject("CrystalRuntime.application.10") '
Set report = App.OpenReport("j:\REPORT.rpt")

Set DB = report.Database
Set Tables = DB.Tables
Set Table1 = Tables.Item(1)
Should I have more Table1 -- do these relate to sub reports?


report.EnableParameterPrompting = False
report.DiscardSavedData

report.ParameterFields.Item(1).AddCurrentValue (currentpractice)

report.ReadRecords

'Set our export options
report.ExportOptions.DestinationType = crEDTDiskFile
report.PaperOrientation = crPortrait
report.PaperSize = crPaperA4

report.ExportOptions.FormatType = crEFTPortableDocFormat
'report.ExportOptions.FormatType = crEFTWordForWindows
report.ExportOptions.DiskFileName = "C:\Reports\Reports_Generated\report.pdf" ' Path to where to drop PDF.

report.ExportOptions.PDFExportAllPages = True
' Export report without user interaction.
report.Export (False)

I not sure what could be wrong - if someone could point me in the right direction that would be great.

Thanks
 
Hi,

I have been looking around the internet and cant seem to find any help.

If anyone has an idea -- I would be very grateful.


report.ParameterFields.Item(1).AddCurrentValue (currentpractice)

There is nothing being added to the Parameter fields.

Am I perhaps missing a dll? Are these needed to add parameter like this?


Sarah
 
I have successfully got a report to work without any subreports. The parameter value is passed and data is successfully added to the report.

My question now is how will I get the whole report to work.

I have 8 subreports - all refer to the same 2 database tables and some also refer to additional database tables.

The parameter field is created in each report and is the same through out.

How do I set it up in the above code.

Do I have to set the parameter object for every subreport. How do I tell it there are a number of subreports.

Set DB = report.Database
Set Tables = DB.Tables
Set Table1 = Tables.Item(1)

Thanks in advance.


 
Hi,

I was just wondering if anyone can help me. i cant seem to find any info out there.

i have created a report with one subreport. The 1st page of the report the parameter values are displayed however on the second (sub report) they are not. Indicating that the parameter values is not being passed to the subreport.

How do I adapt the code above -- to pass the parameter value to the subreport.

It displays correctly in Crystal.

Thanks
 
Depends upon the parameters and your design.

I don't create parameters in subreports if it can be avoided, rather link the main report parameters directly to the fields within the subreports.

Are these parameters used by both the main and subreport?

-k
 
I have removed my parameter fields and now only have one parameter on the main report.

The code now works in the above form and a report is produced from the DTS package.

Thanks for you help. It stopped me going mad.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top