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

Filtering using asp

Status
Not open for further replies.

Damiona

Programmer
Mar 20, 2001
13
0
0
US
I am in need of a resource or some sample code on how to send filters to a report, like on 1 page of asp i select my filters from dropdowns (ex.date range, a persons name and get all the info in the db for that person ect, and then i click a button and it runs the report filtered using the filters from the previous page.
 
Damiona: Try this

<%@ LANGUAGE=&quot;VBSCRIPT&quot; %>
<title>Crystal Reports ASP Example - Changing a Record Selection Formula</title>
<%
'=================================================================================
' WORKING WITH THE REPORT DESIGNER COMPONENT AND ASP TO CHANGE A SELECTION FORMULA
'=================================================================================
'
' CONCEPT
' The Application object created above (oApp) is needed so that we
' can create the report object.
' Once we have created the report object (oRpt), we can then
' gain access to such things the &quot;Selection Formula&quot; in that
' report.
'
' ALWAYS REQUIRED STEPS (contained in AlwaysRequiredSteps.asp)
' - create the application object
' - create the report object
' - open the report
'
' WORK WITH THE SELECTION FORMULA
' - create a session variable for the new selection formula
' - store the new selection formula into the report
'
' MORE ALWAYS REQUIRED STEPS
' - retreive the records
' - create the page engine
'
' DISPLAY THE REPORT
' - display the report using a smart viewer
' = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =



'==================================================================
'==================================================================
' ALWAYS REQUIRED STEPS
'
' Include the file AlwaysRequiredSteps.asp which contains the code
' for steps:
' - create the application object
' - create the report object
' - open the report
%>

<%
' This is the name of the report being used in this example.
' This variable is being used in the AlwaysRequiredSteps.asp
' To use a different report, change it here.

reportname = &quot;SimpleSelectionFormula.rpt&quot;

%>

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

<%
' If it is easier to understand, simply delete the line above,
' and replace it with the entire contents of the file
' AlwaysRequiredSteps.asp
'==================================================================
'==================================================================




'==================================================================
'==================================================================
' WORK WITH THE SELECTION FORMULA
'
' - create a session variable for the new selection formula

SelectionFormulaValue = &quot;{movie.movie}='Jaws'&quot;



' - store the new selection formula into the report

Session(&quot;oRpt&quot;).RecordSelectionFormula = SelectionFormulaValue

Set ParamDefCollection = Session(&quot;oRpt&quot;).Parameterfields


' b. create the session variable, in this case &quot;Param&quot; and
' point it to the specific parameter in the collection we want
' to change


set session(&quot;Param&quot;) = ParamDefCollection


' c. create variable for the new parameter field value to work on
' and point it to the specific parameter field we want to
' change


set MyParam = session(&quot;Param&quot;).Item(1)


' - put the new value into the variable


NewParamValue = &quot;This is the new Parameter value&quot;


' - store the new Parameter field value into the Report Object
' The call to SetCurrentValue uses this syntax:
' SetCurrentValue(new value, parameter field type)

' In this example, because the &quot;new value&quot; for the parameter
' field is stored in a variable, and because VBScript causes
' all variables to be Variants, it is necessary to convert the
' value stored in the variable to the correct data type.
'
' Here is the list of parameter field types and their number,
' and the VBScript calls to convert the variable from a Variant
' to the right data type:
'
' Param Field Type VBScript Call Type Number
'
' NumberField CDbl 7
' CurrencyField CDbl 8
' Boolean CBool 9
' DateField CDate 10
' StringField CStr 12

' The parameter field in this example is a String parameter, so
' we use the value of 12 for the parameter type, and the
' VBScript call CStr()


Call Myparam.SetCurrentValue(CStr(NewParamValue),12)



'==================================================================
'==================================================================
'
' MORE ALWAYS REQUIRED STEPS
' - retreive the records
' - create the page engine
' - create the smart viewer and point it to rptserver.asp
'
%>

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

<%
' If it is easier to understand, simply delete the line above,
' and replace it with the entire contents of the file
' MoreRequiredSteps.asp
'==================================================================
'==================================================================



' INSTANTIATE THE REPORT VIEWER
'
'When using the Crystal Reports in an ASP environment, we use
'the same page-on-demand Report Viewers used with the Crystal Web Component Server.
'There are six Report Viewers:
'
'1. Report Viewer for ActiveX
'2. Report Viewer for Java using Browser JVM
'3. Report Viewer for Standard HTML with Frames
'4. Report Viewer for Standard HTML
'5. Report Viewer for Java Using Java Plugin
'6. Report Viewer for Netscape Plug-in (ActiveX)
'
'The Report Viewer that you use will based on the browser's display capablities.
'For Example, you would not want to instantiate one of the Java viewers if the browser
'did not support Java applets. For purposes on this demo, we have chosen to
'define a viewer. You can through code determine the support capabilities of
'the requesting browser. However that functionality is inherent in the Crystal
'Reports RDC and is beyond the scope of this demonstration app.
'
'We have chosen to leverage the server side include functionality of ASP
'for simplicity sake. So you can use the SmartViewer*.asp files to instantiate
'the smart viewer that you wish to send to the browser. Simply replace the line
'below with the Smart Viewer asp file you wish to use.
'
'The choices are SmartViewerActiveX.asp, SmartViewerJava.asp, JavaPluginViewer.asp,
'ActiveXPluginViewer.asp. SmartViewerHTMLFrame.asp, and SmartViewerHTMLPAge.asp.
'Note that to use this include you must have the appropriate .asp file in the
'same virtual directory as the main ASP page.
'
'*NOTE* For SmartViewerHTMLFrame and SmartViewerHTMLPage, you must also have
'the files framepage.asp and toolbar.asp in your virtual directory.


'=============================================================================
' DISPLAY THE REPORT
' - display the report using a smart viewer
'
' Include one of the Smart Viewers.
' - Report Viewer for ActiveX = SmartViewerActiveX.asp
' - Report Viewer for Java using Browser JVM = SmartViewerJAVA.asp
' - Report Viewer for Standard HTML = SmartViewerHTMLPage.asp
' - Report Viewer for Standard HTML w/ Frames = SmartViewerHTMLFrame.asp
' - Report Viewer for Java Using Java Plugin = JavaPluginViewer.asp
' - Report Viewer for Netscape Plug-in = ActiveXPluginViewer.asp
'=============================================================================
%>


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

<%

'==================================================================
' If it easier for you to conceptualize this code by seeing it all
' contained in a single file, simply delete the line above, and
' replace it with the entire contents of the file being included.
'==================================================================

%>
David C. Monks
david.monks@chase-international.com
Accredited Crystal Decisions Enterprise Partner
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top