Mulitple drop downs

Y

yvette

I am creating a form and would like it to do the following but can't seem to figure it out

I want to be able for the user to select an area, get a second drop down list with all the different employees. When the employee is selected, all of their information is filled in across the page

Is this possible? If not, then how can I do the drop downs so when an area is picked then another list comes up?
 
J

John Nurick

Hi Yvette,

One good general approach is this:

1) Bind the form to a query that returns all the employee information
you need.

2) Create a query that returns a list of employees the way you want them
to appear in the dropdown list. Its SQL view will be something like
this:
SELECT EmployeeID, LastName & ", " & FirstName AS DisplayName,
Area FROM Employees ORDER BY LastName, FirstName;
Save it as qryListEmployees

2) Make sure the magic wand button on the control toolbox is "down" and
then draw a combobox in the form header: this will be your *second*
dropdown list. If the wizard is working properly (mine isn't just
now<g>) it will help you set up the combobox so it (a) shows a list of
all the employees regardless of area and (b) when you select an employee
from the dropdown list, the form finds and displays that employee's
data. Name this one cboSelectEmployee

3) When that is working properly, add another combobox to the form
header. This will be your *first* one, for selecting areas. For this
one, the wizard will be less help. It needs to be unbound (ControlSource
property is empty). The RowSource should be a query that returns a list
of areas, so the dropdown list lets the user select an area. Name it
cboSelectArea.

4) The next thing is to make the selection in cboSelectArea control the
list in the "employees" one. In the cboSelectArea's AfterUpdate() event
procedure, use a VBA statement like this:

Me.cboSelectEmployee.RowSource = "SELECT * " _
& "FROM qryListEmployees WHERE Area = '" _
& Me.cboSelectArea.Value & "';"

5) With it set up this way, when the form first opens the Employees
dropdown will contain a list of all employees. But as soon as the user
selects an area the Employees dropdown will be filtered to just that
area.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top