Passing "OR" into a Parameter query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there any way to pass a string such as "18 or 88" into a parameter query?
 
Hi,


Make a table with one field, two records, one with the numerical value 18,
one with 88. Add more records if more values are desired, without duplicated
values.

Use an inner join to make the intersection:

SELECT myTable.*
FROM myTable INNER JOIN previousTable
ON myTable.FieldName = previousTable.itsFieldName



That is probably one of the most versatile solution that can handle a lot of
records (if you add an index) too.



Hoping it may help,
Vanderghast, Access MVP
 
No you can't, the query will use it as one criteria, and it will look for
records that has "18 or 88" and it won't treat each number as individual.

But if you are using a form, where the use enter the parameter in a text
field, then using code you can change the SQL in the query to include the
filter.
So, for example, if the user enter 8,88
then you can use the code

application.CurrentDb.QueryDefs("QueryName").SQL="Select * From TableName
Where FieldName In(" & Me.[TextFieldNameInTheForm] & ")"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top