Solved

Parameter Query - can you list multiple values?

Posted on 2011-02-12
9
457 Views
Last Modified: 2012-05-11
I have a parameter qry setup and working with a single value.  I would like a user to be able to list multiple values within the prompt field, like you would in qry design using Or.  Is it possible?  I'm looking for them to enter exact values.
0
Comment
Question by:vsllc
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 14

Expert Comment

by:Bill Ross
ID: 34880651
Hi vsllc,

It's best to create a form with a combo box or list box and have the users select the entry then fire the query from their selection.

Regards,

Bill
0
 

Author Comment

by:vsllc
ID: 34880700
Thanks Bill.

Unfortunately, there's 1,000's of possible selections which I think is too long for a combo or list box.  Any alternatives?

If not, I may just have to go with the single value and see if it becomes a major, minor or no issue.
0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 34880723
You might be able to set up cascading combo boxes or listboxes, where a selection in the first would filter the second.  Here is a general description of this setup:

cboSelectCustomer has tblCustomers as its row source.  Its AfterUpdate event sets cboSelectOrder to Null or "", and requeries cboSelectOrder.
cboSelectOrder has tblOrders as its row source, with a criterion of [Forms]![frmSelectOrder]![cboSelectCustomer]
0
 
LVL 31

Accepted Solution

by:
Helen_Feddema earned 500 total points
ID: 34880732
For an example of filtering by multiple selections in a multi-select listbox, see my Access Archon #197.  Here is a link for downloading it:

http://www.helenfeddema.com/Files/accarch197.zip

And here is a screen shot of the form:
Filtering-by-Listbox-Selections.jpg
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 14

Expert Comment

by:Bill Ross
ID: 34882595
Hi again,

Helen's solution is great.  You can also use code in a form or a function to validate the user's input before the query is fired.  You can then send the user a message if they've made a typo or something.

Bill
0
 
LVL 44

Expert Comment

by:GRayL
ID: 34884229
Just so we're clear, you can do this:

SELECT * FROM myTable WHRE fld1 = enterv1 OR fld1 = enterv2 OR fld1 = enterv3;

or

SELECT * FROM myTable WHRE fld1 = enterv1 OR fld2 = enterv2 OR fld3 = enterv3;

I think you are limited to 99 OR clauses in a WHERE statement.
0
 

Author Comment

by:vsllc
ID: 34885358
GRayL - What would the user input look like in the prompt?  Meaning how would they seperate the multiple values they wanted to search?
0
 
LVL 44

Expert Comment

by:GRayL
ID: 34888304
I'm not sure I understand your question?  For each parameter you will get a popup entitled "Enter Parameter Value", under which will be the parameter name you assigned - enterv1, or enterv1, or enterv3 as in my example above.  After entering the responses, the query will produce a recordset returning the values of your parameters.  It is to say you must know beforehand  what fields you want to use, and the construct of the WHERE clause you need to produce the required result.
0
 

Author Comment

by:vsllc
ID: 35118605
OK.  So if the parameter box said "What day of the week?", the user would key in "Monday, or Wednesday" in order to get results for just those two values?
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

910 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now