Solved

Can you have a drop down list in a query

Posted on 2014-03-14
4
1,150 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

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

12 Experts available now in Live!

Get 1:1 Help Now