RowSource Query for ComboBox

K

ksmith

I have two tables that are seperate for a timesheet program. I have it

set up that when you enter a name and date via a combo box on a form it

automatically opens up into another form where you would input hours
worked a day, based on a list generated from a table. What I would
like to do is add a query to that list within the second form that only

returns certain records based on a name. Example if you are doing the
timesheet for Amy Morse, only some project ids would be available for
her to choose from. So basically this is what would like to happen

Task_Id is the combobox list with the project codes listed


and under row source for this combobox i have


SELECT [qryItemList].[Task#], [qryItemList].[T_Des1],
[qryItemList].[T_Des2] FROM qryItemList WHERE
(((qryItemList.[Task#])<>1600016));


the list works fine, it returns the whole list minus the 1600016 task
id.


Now I want to query just the list minus this task when your name is amy

morse or some other name, which you would get for the first form combo
box ([Forms]![First Form]![employee].Name)


Something like this
SELECT [qryItemList].[Task#], [qryItemList].[T_Des1],
[qryItemList].[T_Des2] FROM qryItemList WHERE [Forms]![First
Form]![employee].Name = "Amy Morse",
[qryItemList].[Task#], <>1600016


Any advise appreciated


Thanks


Kim
 
M

MGFoster

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The Name column has to be in the result set of the query "qryItemList."
Ideally, you should have an employee ID that would be in the qryItemList
and the "employee" Combo Box would have 2 columns: employee_id,
employee_name, with the BoundColumn being 1. Then the "employee"
ComboBox RowSource property would look like this (formatted for
clarity):

SELECT [Task#], [T_Des1], [T_Des2]
FROM qryItemList
WHERE employee_id = [Forms]![First Form]![employee]
AND [Task#], <> 1600016

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRJrYw4echKqOuFEgEQKEUACfZ2DcBglHdCBDwde+4LKAuCg0KBYAoKCa
kEk6Cte7ypu5QfBJxH+rr2co
=8jO2
-----END PGP SIGNATURE-----
 
K

ksmith

Thanks, I will try this and let you know.

Kim

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The Name column has to be in the result set of the query "qryItemList."
Ideally, you should have an employee ID that would be in the qryItemList
and the "employee" Combo Box would have 2 columns: employee_id,
employee_name, with the BoundColumn being 1. Then the "employee"
ComboBox RowSource property would look like this (formatted for
clarity):

SELECT [Task#], [T_Des1], [T_Des2]
FROM qryItemList
WHERE employee_id = [Forms]![First Form]![employee]
AND [Task#], <> 1600016

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRJrYw4echKqOuFEgEQKEUACfZ2DcBglHdCBDwde+4LKAuCg0KBYAoKCa
kEk6Cte7ypu5QfBJxH+rr2co
=8jO2
-----END PGP SIGNATURE-----

I have two tables that are seperate for a timesheet program. I have it

set up that when you enter a name and date via a combo box on a form it

automatically opens up into another form where you would input hours
worked a day, based on a list generated from a table. What I would
like to do is add a query to that list within the second form that only

returns certain records based on a name. Example if you are doing the
timesheet for Amy Morse, only some project ids would be available for
her to choose from. So basically this is what would like to happen

Task_Id is the combobox list with the project codes listed


and under row source for this combobox i have


SELECT [qryItemList].[Task#], [qryItemList].[T_Des1],
[qryItemList].[T_Des2] FROM qryItemList WHERE
(((qryItemList.[Task#])<>1600016));


the list works fine, it returns the whole list minus the 1600016 task
id.


Now I want to query just the list minus this task when your name is amy

morse or some other name, which you would get for the first form combo
box ([Forms]![First Form]![employee].Name)


Something like this
SELECT [qryItemList].[Task#], [qryItemList].[T_Des1],
[qryItemList].[T_Des2] FROM qryItemList WHERE [Forms]![First
Form]![employee].Name = "Amy Morse",
[qryItemList].[Task#], <>1600016
 

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