SmileyFace
Programmer
Hey guys! Need some help with this...might be simple but I must be overlooking something here coz it doesn't work! I have 2 Crystal reports which I need to pass parameters to from an asp page. Both of them accept the same parameter, so I have a select statement in the Runreport page which picks what selection formula to use for the report according to which report it is. My reports both accept 2 parameters from another asp page....first is the report name and second is the Ordernumber which is called 'Soeno'. Here is the code....
ReportName = Request.QueryString("ReportName" & ".rpt"
if Request.QueryString("Debug" = "Y" then
Response.Write "ReportName = " & ReportName & "<BR>" & vbcrlf
session("debug"="Y"
end If
' CREATE THE APPLICATION OBJECT
On error resume next
If Not IsObject(session("oApp") or session("oApp" is nothing Then
Set session("oApp" = Server.CreateObject("CrystalRuntime.Application"
'session("oApp".SetMorePrintEngineErrorMessages(True)
End If
' CREATE THE REPORT OBJECT
Path = Request.ServerVariables("PATH_TRANSLATED"
While (Right(Path, 1) <> "\" And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend
'OPEN THE REPORT (but destroy any previous one first)
if session("debug" = "Y" then
Response.Write "exec:Al Path=" & path & "<br>" & vbcrlf
end if
If IsObject(session("oRpt") then
Set session("oRpt" = nothing
End if
On error resume next
if session("debug" = "Y" then
Response.Write "Report=" & path & reportname & "<br>" & vbcrlf
end if
Set session("oRpt" = session("oApp".OpenReport(path & reportname, 1)
If Err.Number <> 0 Then
Response.Write "Error Occurred creating Report Object: " & err.number & Err.Description
Set Session("oRpt" = nothing
Set Session("oApp" = nothing
Response.write "<script language=JavaScript>"
Response.write "setTimeout(""window.close()"", 1500)"
Response.Write "</script> "
'Session.Abandon
Response.End
End If
session("oRpt".MorePrintEngineErrorMessages = False
session("oRpt".EnableParameterPrompting = False
session("oRpt".DiscardSavedData
OrderNum = Request.QueryString("soeno"
'Building the selection formula...
select case reportname
case "soa.rpt"
SelectionFormula = "{soa_header.soeno}= '" & OrderNum & "'"
session("oRpt".RecordSelectionFormula = cstr(SelectionFormula)
case "invoice1.rpt"
SelectionFormula = "{t_invoice.sonum}= '" & OrderNum & "'"
session("oRpt".RecordSelectionFormula = cstr(SelectionFormula)
end select
When I don't use the select statement and just consider one report...like the code shown below, it works fine and accepts the parameter but if I try to use the select statement its as if it doesn't hit that code at all because it will open the reports without passing the selection criteria. Here is the code which works....when I try to open a single report. Any idea why the select statement won't work?
OrderNum = Request.QueryString("soeno"
SelectionFormula = "{soa_header.soeno}= '" & OrderNum & "'"
session("oRpt".RecordSelectionFormula = cstr(SelectionFormula)
Thanks in advance for any help offered!
ReportName = Request.QueryString("ReportName" & ".rpt"
if Request.QueryString("Debug" = "Y" then
Response.Write "ReportName = " & ReportName & "<BR>" & vbcrlf
session("debug"="Y"
end If
' CREATE THE APPLICATION OBJECT
On error resume next
If Not IsObject(session("oApp") or session("oApp" is nothing Then
Set session("oApp" = Server.CreateObject("CrystalRuntime.Application"
'session("oApp".SetMorePrintEngineErrorMessages(True)
End If
' CREATE THE REPORT OBJECT
Path = Request.ServerVariables("PATH_TRANSLATED"
While (Right(Path, 1) <> "\" And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend
'OPEN THE REPORT (but destroy any previous one first)
if session("debug" = "Y" then
Response.Write "exec:Al Path=" & path & "<br>" & vbcrlf
end if
If IsObject(session("oRpt") then
Set session("oRpt" = nothing
End if
On error resume next
if session("debug" = "Y" then
Response.Write "Report=" & path & reportname & "<br>" & vbcrlf
end if
Set session("oRpt" = session("oApp".OpenReport(path & reportname, 1)
If Err.Number <> 0 Then
Response.Write "Error Occurred creating Report Object: " & err.number & Err.Description
Set Session("oRpt" = nothing
Set Session("oApp" = nothing
Response.write "<script language=JavaScript>"
Response.write "setTimeout(""window.close()"", 1500)"
Response.Write "</script> "
'Session.Abandon
Response.End
End If
session("oRpt".MorePrintEngineErrorMessages = False
session("oRpt".EnableParameterPrompting = False
session("oRpt".DiscardSavedData
OrderNum = Request.QueryString("soeno"
'Building the selection formula...
select case reportname
case "soa.rpt"
SelectionFormula = "{soa_header.soeno}= '" & OrderNum & "'"
session("oRpt".RecordSelectionFormula = cstr(SelectionFormula)
case "invoice1.rpt"
SelectionFormula = "{t_invoice.sonum}= '" & OrderNum & "'"
session("oRpt".RecordSelectionFormula = cstr(SelectionFormula)
end select
When I don't use the select statement and just consider one report...like the code shown below, it works fine and accepts the parameter but if I try to use the select statement its as if it doesn't hit that code at all because it will open the reports without passing the selection criteria. Here is the code which works....when I try to open a single report. Any idea why the select statement won't work?
OrderNum = Request.QueryString("soeno"
SelectionFormula = "{soa_header.soeno}= '" & OrderNum & "'"
session("oRpt".RecordSelectionFormula = cstr(SelectionFormula)
Thanks in advance for any help offered!