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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP needed with using Select statement to pass parameters to Crystal

Status
Not open for further replies.

SmileyFace

Programmer
Sep 10, 2002
99
US
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 &quot;ReportName = &quot; & ReportName & &quot;<BR>&quot; & vbcrlf
session(&quot;debug&quot;)=&quot;Y&quot;
end If

' CREATE THE APPLICATION OBJECT
On error resume next
If Not IsObject(session(&quot;oApp&quot;)) or session(&quot;oApp&quot;) is nothing Then
Set session(&quot;oApp&quot;) = Server.CreateObject(&quot;CrystalRuntime.Application&quot;)
'session(&quot;oApp&quot;).SetMorePrintEngineErrorMessages(True)
End If

' CREATE THE REPORT OBJECT
Path = Request.ServerVariables(&quot;PATH_TRANSLATED&quot;)
While (Right(Path, 1) <> &quot;\&quot; And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend


'OPEN THE REPORT (but destroy any previous one first)
if session(&quot;debug&quot;) = &quot;Y&quot; then
Response.Write &quot;exec:Al Path=&quot; & path & &quot;<br>&quot; & vbcrlf
end if

If IsObject(session(&quot;oRpt&quot;)) then
Set session(&quot;oRpt&quot;) = nothing
End if

On error resume next
if session(&quot;debug&quot;) = &quot;Y&quot; then
Response.Write &quot;Report=&quot; & path & reportname & &quot;<br>&quot; & vbcrlf
end if
Set session(&quot;oRpt&quot;) = session(&quot;oApp&quot;).OpenReport(path & reportname, 1)

If Err.Number <> 0 Then
Response.Write &quot;Error Occurred creating Report Object: &quot; & err.number & Err.Description
Set Session(&quot;oRpt&quot;) = nothing
Set Session(&quot;oApp&quot;) = nothing
Response.write &quot;<script language=JavaScript>&quot;
Response.write &quot;setTimeout(&quot;&quot;window.close()&quot;&quot;, 1500)&quot;
Response.Write &quot;</script> &quot;
'Session.Abandon
Response.End
End If

session(&quot;oRpt&quot;).MorePrintEngineErrorMessages = False
session(&quot;oRpt&quot;).EnableParameterPrompting = False
session(&quot;oRpt&quot;).DiscardSavedData


OrderNum = Request.QueryString(&quot;soeno&quot;)
'Building the selection formula...

select case reportname
case &quot;soa.rpt&quot;

SelectionFormula = &quot;{soa_header.soeno}= '&quot; & OrderNum & &quot;'&quot;
session(&quot;oRpt&quot;).RecordSelectionFormula = cstr(SelectionFormula)



case &quot;invoice1.rpt&quot;
SelectionFormula = &quot;{t_invoice.sonum}= '&quot; & OrderNum & &quot;'&quot;
session(&quot;oRpt&quot;).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(&quot;soeno&quot;)

SelectionFormula = &quot;{soa_header.soeno}= '&quot; & OrderNum & &quot;'&quot;



session(&quot;oRpt&quot;).RecordSelectionFormula = cstr(SelectionFormula)


Thanks in advance for any help offered!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top