To get the parameters into your report, you have to first build an array of which checkboxes have been ticked. The checkboxes were build with the normal input tag:
Code:
<INPUT id=theFilter name=theFilter type=checkbox value=" + Filter.getValue() + selected + ">
where
-
is the name of all the checkboxes,
-
is the number of the checkbox, and
-
is whether it should start off selected or not.
In my code, this is controlled by a dll, but if you just want to start with them all selected, you'd put in something like:
Code:
for ( int i=0; i<numYouWant; i++ )
Response.Write("<INPUT id=theFilter name=theFilter type=checkbox value= " + i + " selected>");
Then, when it came to reading them, you would put in:
Code:
var filterArray;
for (i=1; i<=Request.Form( "theFilter" ).count; i++)
filterArray[i] = Request.Form( "theFilter")(i);
Request.Form( "theFilter" )
is an array which asp builds of the checkboxes that are named theFilter (just my name, you can call it what you want) that are checked. So, if you had 5 checkboxes called theFilter, and numbered 0-4, then your filterArray would come out as [0, 1, 4], if they only checked the first, second, and fifth boxes.
The only problem with doing it this way, is that before building your filterArray, you must refresh the page so the asp can pick up the changes. In my case that's fine, because the user hits a button which updates all the data on the screen, and at the same time, builds the URL to run the report. If you wanted to run the report without updating though, you'd have to put all this into a button or something.
To build the string, I have the following:
Code:
Response.Write<A target=new HREF=\"DetailReport.rpt?init=actx");
// this bit loops for the number of prompts I have
var hasBeen = false;
Response.Write("&prompt0=");
for ( int i=0; i<filterArray.length; i++ )
{
if (hasBeen == true) // need to know if we want a comma
Response.Write(",");
Response.Write(filterArray[i]); // Put in the values
hasBeen = true;
}
// when it's all done, close the tag
Response.Write("\">View Detail Report</A>");
This produces a URL like so:
Code:
/DetailReport.rpt?init=actx&prompt0=0&prompt1=1,2,3&prompt2=1,2&prompt3=1,2,3,4
Now, to get these values out in the report, you have to use fomulas. I have 4 parameters defined in my report, all strings, which correspond to the prompts in the URL. The formulas are then of the form:
Code:
Global NumberVar Array statArray;
Local StringVar Array statStrArray;
statStrArray := Split({?status}, ",");
Local numbervar arrayCount := Count(statStrArray);
redim statArray [arrayCount];
Local numbervar nCount;
for nCount:=1 to arrayCount step 1 do
(
statArray[nCount] := tonumber(statStrArray[nCount]);
);
This declares my status Array globally, meaning that the selection formula can access it.
is the parameter, which will contain "1,2,3" when it comes in (or 1,3 or something similar, depending on the boxes that were checked). I then split that out to a string array, removing the commas, and step through that, converting each one to a number and storing it in my statArray.
Then, in the selection formula, I can have:
Code:
Global NumberVar Array statArray; // declare it again so I have access to it
{STATUS_TABLE.Value} in statArray // the sql part
I also have parameters and formulas set up for the other prompts, which are all included with AND statements in the selection formula.
Hope this has been of some assisstance