Solved

Can you have a drop down list in a query

Posted on 2014-03-14
4
1,240 Views
Last Modified: 2014-03-26
I have table called Table.  My table has two fields Cars and Year.
Is there a way to create a query with the two fields and have a dropdown list to select the Year?
0
Comment
Question by:Conernesto
  • 2
4 Comments
 
LVL 84
ID: 39930131
If you have a Dropdown in the underlying table you could do this - but that's a bad idea for many reasons, not the least of which is a query should not be used for something of this nature.

Create a form, and set it to Datasheew view. It'll look like a query but act like a form.
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 39930719
using year as a column name is bad (reserved word/function) - change to yearx

1.set rowsource = select cars, yearx ...
2. set dropdown to 2 columns, bound column = 1, column widths = 0;2
This will hide the year and display the car.
if you want to see year and car then
select yearx, (yearx & ' - ' & car) as carx ...
and do same as 2 above.
0
 

Author Comment

by:Conernesto
ID: 39957380
How do I do the above steps? (i.e. set rowsource and so on)

Thank you.
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 39957431
As I said in my first post:

Add a dropdown to the underlying table, and your combo will show in the query.

1. Open your table in design view
2. select the column where you want the combo to appear
3. Below the field grid, click the "Lookup" tab
4. Set the various properties of that to show the data you want to show.
5. Now use the table in a query, and select the field from Step 2.

After doing that, the query should show the dropdown.

The "various properties" are what coachmann99 is referring to. You'll see them in the "Lookup" tab:

RowSource is a table or query (or SQL statement) that you use to define the values you'll see in the dropdown.

ColumnCount defines the number of columns that are included in the dropdown (generally that's 2, but it could be more)

ColumnWidths allow you to show/hide columns. This is a semicolon delimited set of numbers. A value of "0;1" would hide the first column and set the width of the second to 1 in.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

911 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

22 Experts available now in Live!

Get 1:1 Help Now