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!

Problem with parameter passed to subreport 1

Status
Not open for further replies.

bardlas

Programmer
Jul 18, 2002
13
CA
I'm trying to pass parameters to both main report and subreport(Crystal 8.5 ,each one based on a different ttx file), and export them to PDF files. The main report has two parameter fields on it and subreport has one.
The test code below shows what is being done.

sReportPathRPT = "D:\Reports\RPT\Main.rpt"
Set oCRApp = New CRAXDRT.Application
Set oCRReport = oCRApp.OpenReport(sReportPathRPT, crOpenReportByTempCopy)
oCRReport.DiscardSavedData

Call oCRReport.ParameterFields.GetItemByName("BankName").AddCurrentValue("MainRepParam1")
Call oCRReport.ParameterFields.GetItemByName("UserID").AddCurrentValue("MainRepParam2")

Set oSubreport = oCRReport.OpenSubreport("Subreport")
oSubreport.DiscardSavedData

Call oCRReport.ParameterFields.GetItemByName("Pm-?BankName", "Mif").AddCurrentValue("SubRepParam")
' or Call oSubreport.ParameterFields.GetItemByName("Pm-?BankName").AddCurrentValue("SubRepParam")

oCRReport.EnableParameterPrompting = False
oCRReport.DisplayProgressDialog = False
oCRReport.MorePrintEngineErrorMessages = False
oCRReport.PaperSize = crPaperA4
oCRReport.PaperOrientation = crLandscape
oCRReport.ExportOptions.DiskFileName = "D:\Reports\pdf\TestMain.pdf"

oCRReport.ExportOptions.DestinationType = crEDTDiskFile
oCRReport.ExportOptions.FormatType = crEFTPortableDocFormat
oCRReport.ExportOptions.PDFExportAllPages = True

oCRReport.Export False

oSubreport.EnableParameterPrompting = False
oSubreport.DisplayProgressDialog = False
oSubreport.MorePrintEngineErrorMessages = False
oSubreport.PaperSize = crPaperA4
oSubreport.PaperOrientation = crLandscape

oSubreport.ExportOptions.DiskFileName = "D:\Reports\pdf\TestSub.pdf"

oSubreport.ExportOptions.DestinationType = crEDTDiskFile
oSubreport.ExportOptions.FormatType = crEFTPortableDocFormat
oSubreport.ExportOptions.PDFExportAllPages = True

oSubreport.Export False


the TestMain.pdf file looks fine with the passed parameters appearing on it, but TestSub.pdf does not show its
parameter. I'm sure I'm missing something or improperly linked the subreport parameter field. May be anybody can give me an advice how to resolve this problem, I'd appreciate it a lot!!!

Roman
 
I think the problem is that your parameter is linked to something in the main report. That is why it is called ?pm...
What is it linked to in the main report?

If it is linked to another parameter in the main report, then pass the value to the main report parameter and let the link pass the value to the subreport parameter. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Thanks for your response! Right now it's not connected to any field in "Select data in subreport based on field" combo. What I see in that combo is the fields from the ttx file on it based subreport. Which field if any i should link it to? I think the best way will be if I'll explain what I eventually want to achieve. I want to pass some data to the subreport. This data might be not connected to the main report. In my case it's either not a "UserId" or not a "BankName". Might be the subreport parameter created separately and filled separately from the main report ?
I mean not linked to any field or parameter in the main raport. And if if should I have no clue to which parameter.
Thank again,
Roman

 
If you want you can create a parameter in the main report that is just used to pass data to the subreport parameter. You would link them together and you wouldn't use anything in the select dialogue you mentioned. That is only if you want to use the parameter as a selection criteria.

When you open the link box, what field is listed in the upper right corner when the ?pm- parameter is in the lower left. That is the field it is linked to. The lower right shouldn't be used unless you are using this parameter for selection criteria in the subreport. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
In the upper right corner I have ?BankName and in the left
lower I have ?Pm-?BankName. The lower right check box is not selected. The subreport still does not receive a parameter.

Regards,
Roman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top