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

Parameter query Using IN Operator

Status
Not open for further replies.

coolscan3

Programmer
Oct 23, 2001
40
GB
Is it possible to create a Parameter query using the In operator. The "In" string is in an object on a form
 
I think so, but you would only be able to pass a fixed number of parameters. e.g. ... WHERE Item IN (Param1, Param2, Param3).

To get the flexibility you would not be able to save a query, but you could generate the statement on the fly e.g. Me.RecordSource = "SELECT * FROM MyTable WHERE Item IN (" & Me.txtParams & ")" - where txtParams contains your list of parameters separated by commas (and individually enclosed in single quotes if using strings). You could also use the part after 'WHERE' as your criteria parameter when opening a form.

You will lose a little performance as the query cannot be saved in an optimised state, but more than make up for it in flexibility.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top