List box help

J

JattilaB

on a form I have two list boxes

listbox 1 name is DepID
no control source
control sorce type is table/query
and rowe sorce is
SELECT [Department].[DepID], [Department].[Department] FROM Department ORDER
BY [Department].[Department];

listbox 2 name is EmpID
no control source
control sorce type is table/query
and rowe sorce is
SELECT distinct Employee.FirstName&" "&Employee.LastName,Employee.JobTitle,
Employee.EmpID FROM Employee WHERE
(((Employee.Department)=[forms]![MainMenu]![DepID])) UNION select distinct
null, null FROM Department

what I am trying to achive is have EmpID update and only list the values
that match from DepID

but at the moment I get this for an error
"The number of colums in the two selected tables or queries of union query
do not match"

any ideas?
 
J

Jeff Boyce

Jattila

For a UNION query to work, each SELECT statement needs to have the same
number of fields. The first SELECT statement you provided has two (DepID,
Department). The second has three (a "name", Title, EmpID). Not only do
the number of fields not match, the columns don't "line up".

Could you describe further what you are trying to accomplish, rather than
"how"? I don't understand how you expect the SQL to do an UPDATE...
 
J

JattilaB

:(
what I am trying to acgive is when a feild in depid is clicked then only the
employees show up in the empid from that dep.?

I will try an dlook at it later... now that you slaped me accross the
forhead... :)

but if oyu have an idea that would be good
 
J

Jeff Boyce

No harm intended ... I hope your forehead recovers <g>

Are you describing something like the use of a combobox to select a
Department, then displaying the employees for that department?
 

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