Solved

Can you have a drop down list in a query

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

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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 how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

792 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