Solved

Access Database w/ SQL "Where IN" parameters.

Posted on 2013-11-04
5
318 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Viewers will learn how the fundamental information of how to create a table.

679 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