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!

Passing parameters 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), and print reports from the code. The test code below shows what is being done.

sReportPathRPT = "D:\MainReport.rpt"

Set oCRApp = New CRAXDRT.Application
Set oMainReport = oCRApp.OpenReport(sReportPathRPT, crOpenReportByTempCopy)

oMainReport.DiscardSavedData
oSubreport.DiscardSavedData

oMainReport.ParameterFields.GetItemByName("BankName").AddCurrentValue "MainRepParam1"

oMainReport.ParameterFields.GetItemByName("UserID").AddCurrentValue "MainRepParam2"

Set oSubreport = oMainReport.OpenSubreport("SubReport")

oCRReport.ParameterFields.GetItemByName("Pm-?UserID", "SubReport").AddCurrentValue "SubRepParam"

'or -> oSubreport.ParameterFields.GetItemByName("Pm-?UserID").AddCurrentValue "SubRepParam"

oSubreport.EnableParameterPrompting = False
oMainReport.EnableParameterPrompting = False
oMainReport.DisplayProgressDialog = False
oSubreport.DisplayProgressDialog = False
oMainReport.PrintOut
oSubreport.PrintOut

"Pm-?UserID" is a parameter field on the subreport linked to the parameter field on the main report.

When I print subreport I get the prompt screen "Enter parameters Values" with "Discrete value" set to "SubRepParam" in my case. I don't get this screen when I print the Main report.

Does anyone know how to supress the "Enter parameters Values" prompt screen from appearing ? Any advice would be appreciated!!!

Roman




 
I don't know how close of a fit this will be for you, but the following code works for me:

Dim Report As New CrystalReport1
Dim crxSubreport1 As CRAXDRT.SubreportObject

Report.Database.Tables(1).SetLogOnInfo sParm1, , sParm2, sParm3
Report.ParameterFields(1).AddCurrentValue (sParm4) 'pass account id
'Login to each subreport
Set crxSubreport1 = Report.Subreport1
crxSubreport1.OpenSubreport.Database.Tables(1).SetLogOnInfo sParm1, , sParm2, sParm3

Hope this helps!

DavidTN
 
Thanks for you response. Unfortunately my reports are based
on ttx files.
Regards,
Roman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top