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

Using an Array to filter a recordset 1

Status
Not open for further replies.

aprompt1971

Programmer
Mar 21, 2006
7
GB
I have a form on a page with some checkboxes (the name of each checkbox is the same). The checkboxes are retrieved from a database (Access & ASP) so there might be one or many checkboxes depending on which page the user is on. The value of the checkbox is the ID of the record.

I want the user to select whichever checkboxes they like and on the next page I want to use their selection as the WHERE clause or filter to retrieve data from another table where the ID number being passed is equal to a field in the table.

So currently someone clicks two from a possible four checkboxes and the ID numbers of the two they selected are 16 and 18. On the next page I can retrieve their selection via Request.Querystring and I get an array of 16,18. I can split that array so then I've got ID(0) = 16 and ID(1) = 18 but how do I retrieve from the database the two records whose ID is 16 and 18.

I'm not too good at writing my own recordsets I usually use the Dreamweaver recordset so I'm only used to filtering my recordsets by a single passed variable or cookie.

Sorry if I've not explained that too well, basically i need to say to the database return all records where the ID is equal to X, Y and Z (where XYZ are in an array and there might be just one ID (i.e. X) or there might be many.

Many thanks.
 
Thank you, thank you, thank you ChrisHirst. I played around with FOR.. NEXT loops and IF... THEN statements for hours without getting anywhere but with your help the problem was solved in 2 secs.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top