?
Solved

Query Criertia (Drop Down Box)

Posted on 2013-05-15
11
Medium Priority
?
421 Views
Last Modified: 2013-05-15
is it possible when you ask a question in query criteria like, Which Site?, to have the potential answers as a drop down box and not have to type in the whole answer?
0
Comment
Question by:SweetingA
[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
  • 6
  • 4
11 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39168823
<to have the potential answers as a drop down box >  No
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 39168829
The way to do that is to use a form to gather up your query criteria.

So, for example, the form could have a combobox with various choices available for Site; your query then looks like:

SELECT *
FROM SomeTable
WHERE Site = Forms![NameOfForm]![NameOfCombobox]

Open in new window

0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39168941
or you can do

SELECT *
FROM SomeTable
WHERE Site Like [Which Site] & "*"
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

Author Comment

by:SweetingA
ID: 39169017
I get an error, the syntax in this subquery is incorrect, check syntax and enclose in parentheses.

SELECT * FROM tbl_Site WHERE Site Like [Which Site] & "*"

I tried from a form also and got the same error, any ideas what i am doing wrong?

Thanks for the help
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39169081
try doing a compact and repair,

then try the query again

is  tbl_Site a local table or linked table?

if linked to an SQL table, use


SELECT * FROM tbl_Site WHERE Site Like [Which Site] & "%"
0
 

Author Comment

by:SweetingA
ID: 39169214
No its not a linked table it is a local table, i have tried a compact and repair and still no joy?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39169259
upload a copy of your db


delete the query you created, then do a compact and repair

now create a new query

copy and paste this in SQL view of the query

SELECT *
FROM tbl_Site
WHERE [Site] Like [Which Site] & "*"
0
 

Author Comment

by:SweetingA
ID: 39169291
Attached is the original SQL - what do i change it to?

I was not changing the SQL before i was adding the script to the criteria field, hence the problem, sorry for the confusion

SELECT qry_CO_MonthlyPPM_PreFilter2.Site, qry_CO_MonthlyPPM_PreFilter2.Year, qry_CO_MonthlyPPM_PreFilter2.Month, qry_CO_MonthlyPPM_PreFilter2.[Delivered Quantity], qry_CO_MonthlyPPM_PreFilter2.[Rejected Quantity], qry_CO_MonthlyPPM_PreFilter2.PPM, qry_CO_MonthlyPPM_PreFilter2.SortID
FROM qry_CO_MonthlyPPM_PreFilter2
WHERE (((qry_CO_MonthlyPPM_PreFilter2.Site)=[Which Site?]) AND ((qry_CO_MonthlyPPM_PreFilter2.Year)=Year(Now())))
ORDER BY qry_CO_MonthlyPPM_PreFilter2.Site, qry_CO_MonthlyPPM_PreFilter2.SortID;

Thanks
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1500 total points
ID: 39169334
try this one, create a new query, (so you don't messed your old query)

copy and paste this


SELECT qry_CO_MonthlyPPM_PreFilter2.Site, qry_CO_MonthlyPPM_PreFilter2.Year, qry_CO_MonthlyPPM_PreFilter2.Month, qry_CO_MonthlyPPM_PreFilter2.[Delivered Quantity], qry_CO_MonthlyPPM_PreFilter2.[Rejected Quantity], qry_CO_MonthlyPPM_PreFilter2.PPM, qry_CO_MonthlyPPM_PreFilter2.SortID
FROM qry_CO_MonthlyPPM_PreFilter2
WHERE (((qry_CO_MonthlyPPM_PreFilter2.Site) Like [Which Site?] & "*") AND ((qry_CO_MonthlyPPM_PreFilter2.Year)=Year(Now())))
ORDER BY qry_CO_MonthlyPPM_PreFilter2.Site, qry_CO_MonthlyPPM_PreFilter2.SortID;


in this query, you can type a partial name of site and it will return all that begins with what you typed in the Input box
0
 

Author Closing Comment

by:SweetingA
ID: 39169407
OK its not a pick list or drop down but its better than users typing the whole thing.

Thanks
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39169422
why a Grade of B?

the answer to your original question is at http:#a39168823 

the query is just an alternative method.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

752 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