?
Solved

Access Database w/ SQL "Where IN" parameters.

Posted on 2013-11-04
5
Medium Priority
?
321 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
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 …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

770 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