Suppose you have a form that uses a ReportViewer to preview a report of the grade point average of all students. You include the option of showing students in a specific grade, by using a SpinBox for the grade number, and a CheckBox to enable or disable the grade restriction. From the CheckBox or SpinBox components’ onChange event, you call the following form method to redisplay the report with the latest options:

function viewReport( )

   if form.gradeCheckbox.value // Use grade 

      form.reportViewer1.params[ "grade" ] = form.gradeSpinbox.value 

   else // No grade, remove the element 

      form.reportViewer1.params.removeAll( ) // Only one element, so just removeAll( ) 

   endif 

form.reportViewer1.reExecute( ) // Re-execute report with new parameters 

The .REP file has the following statements in the Header:

if argcount( ) >= 1

   local r 

   r = new GPAReport( ) 

   r.streamSource1.rowset.filter := "GRADE = " + argvector(1) 

   r.render( ) 

   return 

endif

If a parameter is passed, the report’s StreamSource object’s rowset’s filter property is set so that only the specified grade is shown. The report is rendered, and the RETURN statement prevents the execution of the standard report bootstrap code.