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

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
 
Wow! A lot of code.
Typically the problem lies in the way the main and sub reports are linked within Crystal. You provided little detail there. What field are you using to link? Are the types the same in both main and sub? Where in the main repot did you place the sub report?

Look to Crystal, not VB for your answer. Howard Hammerman,

Crystal Reports training, consulting, books, training material, software, and support. Scheduled training in 8 cities.
howard@hammerman.com
800-783-2269
 
Thanks for your response! I tried "to play" with this
parameter "Pm-?BankName" in many different ways. 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? In my case I want to pass a different data to "Pm-?BankName" parameter field , not the same that gets "BankName" parameter field on the main report. More than that "Pm-?BankName" may be should not be "derived" from the "BankName" at all. I hope you understand my explanation and my problem. Might be the subreport parameter created separately and filled separately from the main report ? Th subreport I placed in the Report Footer section of the Main report.
Thanks ,
Roman

 
>Might be the subreport parameter created separately and >filled separately from the main report ?

Yes, that is the heart of your problem. You are linking on the wrong fields. In Crystal you can link the main and sub report on a formula field. That may help.

I don't fully understand all the details, but I think you should re-work your links. Howard Hammerman,
Crystal Reports training, consulting, books, training material,support. HammerLauch program runs reports without Crystal
howard@hammerman.com
800-783-2269
 
Thanks again. Ok, in my case for example if I want the data passed to the "BankName" parameter field on the main report
to appear on the linked "Pm-?BankName" parameter field of the subreport ? The "Select data in subreport based on field" check box in the lower right corner of the "Subreport Links" screen is not selected.

Regards,
Roman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top