Solved

Query Criertia (Drop Down Box)

Posted on 2013-05-15
11
415 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
  • 6
  • 4
11 Comments
 
LVL 119

Expert Comment

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

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 119

Expert Comment

by:Rey Obrero
ID: 39168941
or you can do

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

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 119

Expert Comment

by:Rey Obrero
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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 119

Expert Comment

by:Rey Obrero
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 119

Accepted Solution

by:
Rey Obrero earned 500 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 119

Expert Comment

by:Rey Obrero
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

708 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

10 Experts available now in Live!

Get 1:1 Help Now