Hello CR people. I'm new at CR so I'm quite confused on how to pass parameters to a report with an unlinked subreport(the subreport uses an entirely different stored procedure as of the main report). When I preview my report on the CR design panel..I get the results of both reports when I supply them with parameters needed by both main and sub reports. The problem seems to be passing parameters on the subreport using ASP because when I run my app without the subreport on ASP, it runs great. However, when I try passing parameters of the main and the sub report programmatically, I get an "invalid name error" . I can't seem to pass the subreport parameters and the main report parameters at the same time just like what I'm doing when i preview my whole report on the CR design panel.
Here's my code which runs fine without passing my sub-report parameters.The error seems to come mysteriously from the "select case" portion.
Or, is there an issue when passing main and sub-report parameters all at the same time then executing the report? Can't I just pass them to my .rpt all at the same time since I designed my .rpt (report) to expect all these parameters while pointing the main and the sub report to their own respective stored procedures?
FUNCTION GenerateCrystalReport_8(p_strReportName, p_xmlParams)
DIM objCrystal, objReport, objPageOptions, objExportOptions, objXMLParams
DIM intI, strRPTPath, strTempFilename
DIM strParamName, strParamType, strParamValue
CONST crBooleanField = 9
CONST crDateField = 10
CONST crDateTimeField = 16
CONST crNumberField = 7
CONST crStringField = 12
strTempFilename = GenerateTempFilename()
strRPTPath = "../../CrystalReports/" & p_strReportName & ".rpt"
SET objCrystal = Server.CreateObject("CrystalRuntime.Application"
objCrystal.LogOnServer "P2SSQL.DLL","SQL_Server","PASS","progid","progid"
SET objReport = objCrystal.OpenReport(Server.MapPath(strRPTPath),1)
IF LEN(TRIM(p_xmlParams)) <> 0 THEN
SET objXMLParams = GetXMLDoc(p_xmlParams)
FOR intI = 1 TO objXMLParams.documentElement.ChildNodes.Length
strParamName = objXMLParams.documentElement.ChildNodes(intI - 1).getAttribute("name"
strParamType = Lcase(objXMLParams.documentElement.ChildNodes(intI - 1).getAttribute("type")
strParamValue = objXMLParams.documentElement.ChildNodes(intI - 1).Text
SELECT CASE strParamType
CASE "number"
CALL objReport.ParameterFields.GetItemByName(strParamName).SetCurrentValue(CInt(strParamValue), crNumberField)
CASE "string"
CALL objReport.ParameterFields.GetItemByName(strParamName).SetCurrentValue(CStr(strParamValue), crStringField)
CASE "boolean"
' do nothing
CASE "date"
CALL objReport.ParameterFields.GetItemByName(strParamName).SetCurrentValue(cDate(strParamValue), crDateTimeField)
CASE "datetime"
'do nothing
END SELECT
NEXT
SET objXMLParams = NOTHING
END IF
Set objExportOptions = objReport.ExportOptions
objExportOptions.DiskFileName = Server.MapPath("../../CrystalReports/Results" & "\" & strTempFilename & ".pdf"
objExportOptions.FormatType = 31
objExportOptions.DestinationType = 1
objReport.Export False
ON ERROR RESUME NEXT
IF Err.Number = 0 THEN
GenerateCrystalReport_8 = "<pdffile><![CDATA[" & "../../CrystalReports/Results/" & strTempFilename & ".PDF]]></pdffile>"
ELSE
GenerateCrystalReport_8 = cst_Fail
CALL DisplayError("IPMS - Crystal Report Error", intRet, Err.Number & ": " & Err.Description)
Response.End
END IF ... blah..blah..blah...
Here's my code which runs fine without passing my sub-report parameters.The error seems to come mysteriously from the "select case" portion.
Or, is there an issue when passing main and sub-report parameters all at the same time then executing the report? Can't I just pass them to my .rpt all at the same time since I designed my .rpt (report) to expect all these parameters while pointing the main and the sub report to their own respective stored procedures?
FUNCTION GenerateCrystalReport_8(p_strReportName, p_xmlParams)
DIM objCrystal, objReport, objPageOptions, objExportOptions, objXMLParams
DIM intI, strRPTPath, strTempFilename
DIM strParamName, strParamType, strParamValue
CONST crBooleanField = 9
CONST crDateField = 10
CONST crDateTimeField = 16
CONST crNumberField = 7
CONST crStringField = 12
strTempFilename = GenerateTempFilename()
strRPTPath = "../../CrystalReports/" & p_strReportName & ".rpt"
SET objCrystal = Server.CreateObject("CrystalRuntime.Application"
objCrystal.LogOnServer "P2SSQL.DLL","SQL_Server","PASS","progid","progid"
SET objReport = objCrystal.OpenReport(Server.MapPath(strRPTPath),1)
IF LEN(TRIM(p_xmlParams)) <> 0 THEN
SET objXMLParams = GetXMLDoc(p_xmlParams)
FOR intI = 1 TO objXMLParams.documentElement.ChildNodes.Length
strParamName = objXMLParams.documentElement.ChildNodes(intI - 1).getAttribute("name"
strParamType = Lcase(objXMLParams.documentElement.ChildNodes(intI - 1).getAttribute("type")
strParamValue = objXMLParams.documentElement.ChildNodes(intI - 1).Text
SELECT CASE strParamType
CASE "number"
CALL objReport.ParameterFields.GetItemByName(strParamName).SetCurrentValue(CInt(strParamValue), crNumberField)
CASE "string"
CALL objReport.ParameterFields.GetItemByName(strParamName).SetCurrentValue(CStr(strParamValue), crStringField)
CASE "boolean"
' do nothing
CASE "date"
CALL objReport.ParameterFields.GetItemByName(strParamName).SetCurrentValue(cDate(strParamValue), crDateTimeField)
CASE "datetime"
'do nothing
END SELECT
NEXT
SET objXMLParams = NOTHING
END IF
Set objExportOptions = objReport.ExportOptions
objExportOptions.DiskFileName = Server.MapPath("../../CrystalReports/Results" & "\" & strTempFilename & ".pdf"
objExportOptions.FormatType = 31
objExportOptions.DestinationType = 1
objReport.Export False
ON ERROR RESUME NEXT
IF Err.Number = 0 THEN
GenerateCrystalReport_8 = "<pdffile><![CDATA[" & "../../CrystalReports/Results/" & strTempFilename & ".PDF]]></pdffile>"
ELSE
GenerateCrystalReport_8 = cst_Fail
CALL DisplayError("IPMS - Crystal Report Error", intRet, Err.Number & ": " & Err.Description)
Response.End
END IF ... blah..blah..blah...