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 Mike Lewis 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 a crystal report

Status
Not open for further replies.

SmileyFace

Programmer
Sep 10, 2002
99
US
This might be an easy one but I am not very familiar with Crystal. I have copied a report to from one server to another and am trying to open from a web page using asp. The report accesses a MS Access database to pull out information. It passes an order number from the system to the report which pulls up information for that particular order.

The current system uses VB to pass the Order Num onto the report. So basically I know that the report accepts a parameter. But if I run the report directly from the design view it does not explicitly ask me for the order num, just opens up a blank report with the design. The 'Show SQL Query' under database in the report is disabled so I cannot view it. My question is how do I find out where the parameter has been set inside of the report? I have checked 'Selection Expert' and there is nothing there. Any help here will be really appreciated. THANKS in advance!!
 
The parameter may not exist within the report at all, rather a record selection is passed from VB.

Check to see if the parameter exists (Insert->Field Object->Check Parameters), and don't worry over the Show SQL, that doesn't guarantee anything regarding parameters.

The Selection Expert is a toy, to check the record selection formula, use Report->Edit Selection Formula, and check the Record and the Group options.

Now you know how to tell IF a parameter is set in the report, and WHERE it would be.

Do you have a task, or was this just for informational purposes?

-k
 
Hey thanks! I guess you are probably right. The selection criteria is set inside of VB. I couldn't find any parameters set in the report. Then maybe you can help me out here.....I am helping convert a Vb application over to ASP to make it web based. With the little Crystal knowledge I have I was able to use what we have set up for our other websystems to open the Crystal Reports Viewer. I have a page which is basically an Order Review page where I should be able to print the order from the menu. When I click on print order, I would like it to pass the order number over to the report so that it can pull information for that order from an Access database. SO what I did was connect to the database using ASP and retrieve the order number.....called Soeno. Right now since it is still in developmental stages I am just trying to pass over an existant order number directly. Here is the code I use for that....

Dim cnn
Dim rs
Dim strSQL
Dim Soeno

Set cnn = Server.CreateObject("ADODB.Connection")
sDataDir = Server.MapPath ("oms\oms32\reports.mdb")
cnn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & sDataDir & ";"

Set rs = Server.CreateObject("ADODB.Recordset")
strSQL = "select * from soa_header where soeno='S12345'"
rs.Open strSQL, cnn
Do while not rs.EOF
Soeno = rs("soeno")
'Response.Write(Soeno)
rs.MoveNext
Loop

rs.Close
set rs = Nothing
Set cnn = Nothing

This line actaully passes the Order Number over to the runreport.asp page.....soa.rpt is the report in question. How do I pass the Soeno from this page to the runrepot.asp page?. Is it like this....

menu[2][1] = new Item('Print Order', 'RunReport.asp?ReportName=soa.rpt?Soeno<%=rs(&quot;soeno&quot;)%>', '', defLength, 0, 0);

But the above is Javascript code...how do I embed asp in that? I am not sure you know asp too well, but if u do it would be great if you can help!

The runreport.asp code is as follows:

<%@ LANGUAGE=&quot;VBSCRIPT&quot; %>

<!-- #include file=&quot;SmartViewerActiveX.asp&quot; -->

<%

reportname = Request.QueryString(&quot;ReportName&quot;)
BeginDate = Request.QueryString(&quot;BeginDate&quot;)
EndDate = Request.QueryString(&quot;EndDate&quot;)
Soeno = Request.QueryString(&quot;Soeno&quot;)


'reportname = &quot;DailyDealerReport.rpt&quot;
' CREATE THE APPLICATION OBJECT
If Not IsObject (session(&quot;oApp&quot;)) Then
Set session(&quot;oApp&quot;) = Server.CreateObject(&quot;CrystalRuntime.Application&quot;)
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 IsObject(session(&quot;oRpt&quot;)) then
Set session(&quot;oRpt&quot;) = nothing
End if

' rpttoview = &quot;D:\Webdata\Release\oms2003\soa.rpt&quot;
' Set session(&quot;oRpt&quot;) = session(&quot;oApp&quot;).OpenReport(rpttoview,1)
set session(&quot;oRpt&quot;) = session(&quot;oApp&quot;).OpenReport(path & reportname,1)
session(&quot;oRpt&quot;).MorePrintEngineErrorMessages = False
session(&quot;oRpt&quot;).EnableParameterPrompting = False
session(&quot;oRpt&quot;).DiscardSavedData

'check for parameters
select case reportname

case &quot;DailyDealerReport.rpt&quot;
set session(&quot;ParamCollection&quot;) = Session(&quot;oRpt&quot;).Parameterfields
set Param1 = session(&quot;ParamCollection&quot;).Item(1)
Call Param1.SetCurrentValue (cstr(BeginDate),12)

case &quot;DailyDealerReportControl.rpt&quot;
set session(&quot;ParamCollection&quot;) = Session(&quot;oRpt&quot;).Parameterfields
set Param1 = session(&quot;ParamCollection&quot;).Item(1)
Call Param1.SetCurrentValue (cstr(BeginDate),12)

case &quot;DailyDealerLabels.rpt&quot;
set session(&quot;ParamCollection&quot;) = Session(&quot;oRpt&quot;).Parameterfields
set Param1 = session(&quot;ParamCollection&quot;).Item(1)
Call Param1.SetCurrentValue (cstr(BeginDate),12)

case &quot;WeeklyManufacturerReportSpa.rpt&quot;
set session(&quot;ParamCollection&quot;) = Session(&quot;oRpt&quot;).Parameterfields
set Param1 = session(&quot;ParamCollection&quot;).Item(1)
Call Param1.SetCurrentValue (cstr(BeginDate),12)

set Param2 = session(&quot;ParamCollection&quot;).Item(2)
Call Param2.SetCurrentValue (cstr(EndDate),12)

set Param3 = session(&quot;ParamCollection&quot;).Item(3)
Call Param3.SetCurrentValue (cstr(&quot;S&quot;), 12)

set Param4 = session(&quot;ParamCollection&quot;).Item(4)
Call Param4.SetCurrentValue (cstr(&quot;%&quot;), 12)

case &quot;WeeklyManufacturerReportSpaControl.rpt&quot;
set session(&quot;ParamCollection&quot;) = Session(&quot;oRpt&quot;).Parameterfields
set Param1 = session(&quot;ParamCollection&quot;).Item(1)
Call Param1.SetCurrentValue (cstr(BeginDate),12)

set Param2 = session(&quot;ParamCollection&quot;).Item(2)
Call Param2.SetCurrentValue (cstr(EndDate),12)

set Param3 = session(&quot;ParamCollection&quot;).Item(3)
Call Param3.SetCurrentValue (cstr(&quot;S&quot;), 12)

set Param4 = session(&quot;ParamCollection&quot;).Item(4)
Call Param4.SetCurrentValue (cstr(&quot;%&quot;), 12)

case &quot;WeeklyManufacturerReportBath.rpt&quot;
set session(&quot;ParamCollection&quot;) = Session(&quot;oRpt&quot;).Parameterfields
set Param1 = session(&quot;ParamCollection&quot;).Item(1)
Call Param1.SetCurrentValue (cstr(BeginDate),12)

set Param2 = session(&quot;ParamCollection&quot;).Item(2)
Call Param2.SetCurrentValue (cstr(EndDate),12)

set Param3 = session(&quot;ParamCollection&quot;).Item(3)
Call Param3.SetCurrentValue (cstr(&quot;B&quot;), 12)

set Param4 = session(&quot;ParamCollection&quot;).Item(4)
Call Param4.SetCurrentValue (cstr(&quot;%&quot;), 12)

case &quot;WeeklyManufacturerReportCanada.rpt&quot;
set session(&quot;ParamCollection&quot;) = Session(&quot;oRpt&quot;).Parameterfields
set Param1 = session(&quot;ParamCollection&quot;).Item(1)
Call Param1.SetCurrentValue (cstr(BeginDate),12)

set Param2 = session(&quot;ParamCollection&quot;).Item(2)
Call Param2.SetCurrentValue (cstr(EndDate),12)

set Param3 = session(&quot;ParamCollection&quot;).Item(3)
Call Param3.SetCurrentValue (cstr(&quot;S&quot;), 12)

set Param4 = session(&quot;ParamCollection&quot;).Item(4)
Call Param4.SetCurrentValue (cstr(&quot;C&quot;), 12)

case &quot;WeeklyManufacturerReportCanadaBath.rpt&quot;
set session(&quot;ParamCollection&quot;) = Session(&quot;oRpt&quot;).Parameterfields
set Param1 = session(&quot;ParamCollection&quot;).Item(1)
Call Param1.SetCurrentValue (cstr(BeginDate),12)

set Param2 = session(&quot;ParamCollection&quot;).Item(2)
Call Param2.SetCurrentValue (cstr(EndDate),12)

set Param3 = session(&quot;ParamCollection&quot;).Item(3)
Call Param3.SetCurrentValue (cstr(&quot;B&quot;), 12)

set Param4 = session(&quot;ParamCollection&quot;).Item(4)
Call Param4.SetCurrentValue (cstr(&quot;C&quot;), 12)

case &quot;CallOutcomes.rpt&quot;
set session(&quot;ParamCollection&quot;) = Session(&quot;oRpt&quot;).Parameterfields
set Param1 = session(&quot;ParamCollection&quot;).Item(1)
Call Param1.SetCurrentValue (cstr(BeginDate),12)

set Param2 = session(&quot;ParamCollection&quot;).Item(2)
Call Param2.SetCurrentValue (cstr(EndDate),12)

case &quot;RequestSourcesBath.rpt&quot;
set session(&quot;ParamCollection&quot;) = Session(&quot;oRpt&quot;).Parameterfields
set Param1 = session(&quot;ParamCollection&quot;).Item(1)
Call Param1.SetCurrentValue (cstr(BeginDate),12)

set Param2 = session(&quot;ParamCollection&quot;).Item(2)
Call Param2.SetCurrentValue (cstr(EndDate),12)

set Param3 = session(&quot;ParamCollection&quot;).Item(3)
Call Param3.SetCurrentValue (cstr(&quot;B&quot;), 12)

case &quot;RequestSourcesSpa.rpt&quot;
set session(&quot;ParamCollection&quot;) = Session(&quot;oRpt&quot;).Parameterfields
set Param1 = session(&quot;ParamCollection&quot;).Item(1)
Call Param1.SetCurrentValue (cstr(BeginDate),12)

set Param2 = session(&quot;ParamCollection&quot;).Item(2)
Call Param2.SetCurrentValue (cstr(EndDate),12)

set Param3 = session(&quot;ParamCollection&quot;).Item(3)
Call Param3.SetCurrentValue (cstr(&quot;S&quot;), 12)

case &quot;LeadsByChannel.rpt&quot;
set session(&quot;ParamCollection&quot;) = Session(&quot;oRpt&quot;).Parameterfields
set Param1 = session(&quot;ParamCollection&quot;).Item(1)
Call Param1.SetCurrentValue (cstr(BeginDate),12)

set Param2 = session(&quot;ParamCollection&quot;).Item(2)
Call Param2.SetCurrentValue (cstr(EndDate),12)

set Param3 = session(&quot;ParamCollection&quot;).Item(3)
Call Param3.SetCurrentValue (cstr(&quot;%&quot;), 12)

case &quot;ManufacturerReferral.rpt&quot;, &quot;DealerReferral.rpt&quot;, &quot;CallPrompts.rpt&quot;
set session(&quot;ParamCollection&quot;) = Session(&quot;oRpt&quot;).Parameterfields
set Param1 = session(&quot;ParamCollection&quot;).Item(1)
Call Param1.SetCurrentValue (cstr(BeginDate),12)

set Param2 = session(&quot;ParamCollection&quot;).Item(2)
Call Param2.SetCurrentValue (cstr(EndDate),12)

case &quot;soa.rpt&quot;
set session(&quot;ParamCollection&quot;) = Session(&quot;oRpt&quot;).Parameterfields
set Param1 = session(&quot;ParamCollection&quot;).Item(1)
Call Param1.SetCurrentValue (cstr(Soeno),12)





case &quot;ManufacturerList.rpt&quot;
case &quot;ActiveDealerList.rpt&quot;
case &quot;ActiveDealerLabels.rpt&quot;
case &quot;ActiveMFGLabels.rpt&quot;
case &quot;DealersZeroLatLong.rpt&quot;
case &quot;DealersNoProds.rpt&quot;
'case &quot;soa.rpt&quot;

case else
set session(&quot;ParamCollection&quot;) = Session(&quot;oRpt&quot;).Parameterfields
set Param1 = session(&quot;ParamCollection&quot;).Item(1)
Call Param1.SetCurrentValue (cstr(BeginDate),12)

set Param2 = session(&quot;ParamCollection&quot;).Item(2)
Call Param2.SetCurrentValue (cstr(EndDate),12)
end select

If IsObject(session(&quot;oPageEngine&quot;)) Then
set session(&quot;oPageEngine&quot;) = nothing
End If
set session(&quot;oPageEngine&quot;) = session(&quot;oRpt&quot;).PageEngine


This is the smartviewerActiveX.asp page code....

<%
'This file contains the HTML code to instantiate the Smart Viewer ActiveX.
'
'You will notice that the Report Name parameter references the rptserver.asp file.
'This is because the report pages are actually created by rptserver.asp.
'Rptserver.asp accesses session(&quot;oApp&quot;), session(&quot;oRpt&quot;) and session(&quot;oPageEngine&quot;)
'to create the report pages that will be rendered by the ActiveX Smart Viewer.
'
%>
<HTML>
<HEAD>
<TITLE>Ineos Bath and Spa Report System v1.0</TITLE>
</HEAD>
<BODY BGCOLOR=1E457B LANGUAGE=VBScript ONLOAD=&quot;Page_Initialize&quot;>

<OBJECT ID=&quot;CRViewer&quot;
CLASSID=&quot;CLSID:C4847596-972C-11D0-9567-00A0C9273C2A&quot;
WIDTH=100% HEIGHT=95%
CODEBASE=&quot;/viewer/activeXViewer/activexviewer.cab#Version=8,0,0,224&quot;>
<PARAM NAME=&quot;EnableRefreshButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableGroupTree&quot; VALUE=1>
<PARAM NAME=&quot;DisplayGroupTree&quot; VALUE=1>
<PARAM NAME=&quot;EnablePrintButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableExportButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableDrillDown&quot; VALUE=1>
<PARAM NAME=&quot;EnableSearchControl&quot; VALUE=1>
<PARAM NAME=&quot;EnableAnimationControl&quot; VALUE=1>
<PARAM NAME=&quot;EnableZoomControl&quot; VALUE=1>
</OBJECT>

<SCRIPT LANGUAGE=&quot;VBScript&quot;>
<!--
Sub Page_Initialize
On Error Resume Next
Dim webBroker
Set webBroker = CreateObject(&quot;WebReportBroker.WebReportBroker&quot;)
if ScriptEngineMajorVersion < 2 then
window.alert &quot;IE 3.02 users on NT4 need to get the latest version of VBScript or install IE 4.01 SP1. IE 3.02 users on Win95 need DCOM95 and latest version of VBScript, or install IE 4.01 SP1. These files are available at Microsoft's web site.&quot;
CRViewer.ReportName = &quot;rptserver.asp&quot;
else
Dim webSource
Set webSource = CreateObject(&quot;WebReportSource.WebReportSource&quot;)
webSource.ReportSource = webBroker
webSource.URL = &quot;rptserver.asp&quot;
webSource.PromptOnRefresh = True
CRViewer.ReportSource = webSource
end if
CRViewer.ViewReport
End Sub
-->
</SCRIPT>

</BODY>
</HTML>

So basically using these pages I need to open the soa.rpt file passing it the soeno. Now does this Soeno automatically get passed to the report in the runreport.as page and if so how does Crystal accept it and use it to retireve just that information from the database? Could you tell me how to do this? Thanks so much for any hep offered.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top