Multiple Parameter Query from Form

Saaden

New Member
Joined
Aug 4, 2005
Messages
24
Hey guys, Im trying to setup a form that allows users to search for information but I need to base it out on 9 different fields. The kicker is that I need for the query to limit based on the entries but if nothing is entered then to treat it as a wildcard. I have managed to get the query to work using only 2 criteria fields and the SQL is quite long, I was hoping that someone here might be able to point me in a more efficient direction of handling this. Thanks for any help

/code
SELECT tblMain.Department, tblCountdetail.[Part no]
FROM tblMain INNER JOIN tblCountdetail ON tblMain.[Count no] = tblCountdetail.[Count no]
WHERE (((tblMain.Department) Like [Forms]![frmCountEditReview]![txtdepartment]) AND ((tblCountdetail.[Part no]) Like [Forms]![frmCountEditReview]![txtsku])) OR (((tblCountdetail.[Part no]) Like [Forms]![frmCountEditReview]![txtsku]) AND (([Forms]![frmCountEditReview]![txtdepartment]) Is Null)) OR (((tblMain.Department) Like [Forms]![frmCountEditReview]![txtdepartment]) AND (([Forms]![frmCountEditReview]![txtsku]) Is Null)) OR ((([Forms]![frmCountEditReview]![txtdepartment]) Is Null) AND (([Forms]![frmCountEditReview]![txtsku]) Is Null));
/code

That is the SQL behind getting 2 fields to work
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Use the Iif function.

Something like this perhaps.

Like Iif(IsNull([Forms]![frmCountEditReview]![txtdepartment]), "*", [Forms]![frmCountEditReview]![txtdepartment]))

Or use &, something like this maybe.

Like "*"& [Forms]![frmCountEditReview]![txtdepartment]) & "*"
 
Upvote 0

Forum statistics

Threads
1,213,506
Messages
6,114,024
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top