Solved

Access Database w/ SQL "Where IN" parameters.

Posted on 2013-11-04
5
317 Views
Last Modified: 2013-11-09
Sample Data:

Roll			Description			Price
========		==========			=======
2			Test				1.00
3			Test #2				2.00
...
8500			Final Test			499.00

Open in new window


I'm trying to allow my user to type: "3, 4, 800, 6789" and for my database to pull up a list of those rows.

I know that the query would look like this:

"SELECT * FROM `Inventory` WHERE IN `Roll` (3, 4, 800, 6789)"

I just can't pick apart all these "VBA", "Stored Procedure", and other posts about the topic because it seems so easy and obvious to do.

Ask user for input, plug the input into query. What am I missing and please be detailed since I come from the PHP MVC and MySQL world.
0
Comment
Question by:advantagec
  • 3
5 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39621479
the syntax is

"SELECT * FROM Inventory  WHERE Roll  IN(3, 4, 800, 6789)"

if Roll is of Text Data type, you need to enclosed the values with quotes or single quotes


"SELECT * FROM Inventory  WHERE Roll  IN('3', '4', '800', '6789')"
0
 

Author Comment

by:advantagec
ID: 39621508
You ignored the question. I don't care about my syntax, I need to know how to parameterize a "WHERE IN" query in Access 2013.
0
 

Accepted Solution

by:
advantagec earned 0 total points
ID: 39621615
For anyone in the future:

http://support.microsoft.com/kb/100131

See Method #2. Extremely simple and it just worked. Just don't make the same mistake I did and name your module "InParam", since that's already the name of a function and it will error.
0
 

Author Closing Comment

by:advantagec
ID: 39635426
The only real answer, and it worked.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question