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!

filtering records from dropdowns

Status
Not open for further replies.

ABinBoston

Programmer
Nov 6, 2001
22
US
I have a page showing a list of companies, employees and departments

I'd like to click a dropdown to filter the records by company, then once again by departments.. for that company.

Any help appreciated!

AB
 
Hi

Try this: Have two combo boxes containing your lists of companies and departments. Make sure that the value of each entry of the combo is the company/department name (standard practice). Add an extra <option> at the top which says &quot;Show all Companies&quot; or &quot;all departments&quot;

When the user submits the page to filter the records construct the SQL for the recordset based on the values choosen by the user.

If request.form(&quot;company&quot;)=&quot;Show all Companies&quot; then
sqlcode = &quot;&quot;
Else
sqlcode = &quot; WHERE company='&quot; & request.form(&quot;company&quot;) & &quot;' &quot;
if request.form(&quot;department&quot;)<>&quot;all departments&quot; then
sqlcode = sqlcode & &quot; AND department='&quot; & request.form(&quot;department&quot;) & &quot;' &quot;
End if
End if

Then in your recordset SQL code make it (like) this:

rsEmployees.source = &quot;SELECT * FROM employees &quot; & sqlcode

You will now have the recordset you require and you can choose to not show the recordset if no filters have been applied

Derren [The only person in the world to like Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top