Using combobox to run a query

B

Brendanpeek

Hello

I need the code or any help to be able to get a combobox to run a query
based apon the value selected within the combobox, i also dont know how to
make the query variable and linked to the combobox so that i dont have to
produce loads of queries.

Thank you for your time.
 
P

Piet Linden

Hello

I need the code or any help to be able to get a combobox to run a query
based apon the value selected within the combobox, i also dont know how to
make the query variable and linked to the combobox so that i dont have to
produce loads of queries.

Thank you for your time.

SELECT Field1, Field2....
FROM MyTable
WHERE Field1=Forms![MyOpenForm]![MyComboBox]

In the afterupdate event of the combobox,
DoCmd.OpenQuery "MyQuery"
 
B

Brendanpeek

SELECT NRTS.Item, NRTS.Description, NRTS.[NRTS No], NRTS.[Serial Number],
NRTS.[Date Issued], NRTS.[Cal Due], NRTS.[Allocated To], NRTS.[Pat due Date],
NRTS.Comments
FROM NRTS
WHERE Allocated To=Forms![Main]![Combo5];

this is not working where have i gone wrong?

Thank you for your time.

Piet Linden said:
Hello

I need the code or any help to be able to get a combobox to run a query
based apon the value selected within the combobox, i also dont know how to
make the query variable and linked to the combobox so that i dont have to
produce loads of queries.

Thank you for your time.

SELECT Field1, Field2....
FROM MyTable
WHERE Field1=Forms![MyOpenForm]![MyComboBox]

In the afterupdate event of the combobox,
DoCmd.OpenQuery "MyQuery"
 
B

Brendanpeek

found the first error.
WHERE [Allocated To]=Forms![Main]![Combo5];
but with this now soved when i select a name from the combobox the query
runs but dose not return any records

Please Help.

Brendanpeek said:
SELECT NRTS.Item, NRTS.Description, NRTS.[NRTS No], NRTS.[Serial Number],
NRTS.[Date Issued], NRTS.[Cal Due], NRTS.[Allocated To], NRTS.[Pat due Date],
NRTS.Comments
FROM NRTS
WHERE Allocated To=Forms![Main]![Combo5];

this is not working where have i gone wrong?

Thank you for your time.

Piet Linden said:
Hello

I need the code or any help to be able to get a combobox to run a query
based apon the value selected within the combobox, i also dont know how to
make the query variable and linked to the combobox so that i dont have to
produce loads of queries.

Thank you for your time.

SELECT Field1, Field2....
FROM MyTable
WHERE Field1=Forms![MyOpenForm]![MyComboBox]

In the afterupdate event of the combobox,
DoCmd.OpenQuery "MyQuery"
 
M

Marshall Barton

Brendanpeek said:
found the first error.
WHERE [Allocated To]=Forms![Main]![Combo5];
but with this now soved when i select a name from the combobox the query
runs but dose not return any records


Check to make sure the combo box's BoundColumn setting
corresponds to the [Allocated To] field in the table.
 
B

Brendanpeek

From another forum i found out it was because the column was set to two
instead of one. but thank you for your help

Marshall Barton said:
Brendanpeek said:
found the first error.
WHERE [Allocated To]=Forms![Main]![Combo5];
but with this now soved when i select a name from the combobox the query
runs but dose not return any records


Check to make sure the combo box's BoundColumn setting
corresponds to the [Allocated To] field in the table.
 

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