Using a Combo Box Drop Down List as Query Criteria

J

jimswinder

How do you have a query use one of the values in a drop down list? When I
select one of the values, it just returns everything...not just the value in
the Combo box.
 
O

Ofer

Try this

Select * From TableName Where FieldName = Forms![FormName]![ComboName]

Now, if you try to filter on the second column in a combo, use this

Select * From TableName Where FieldName =
Forms![FormName]![ComboName].column(1)

The column number start from 0, the first column doesnt need to be specify
 
J

jimswinder

[Query - Catalog Append Table] is a select query which queries a table
(Catalog Append Table) that has been appeneded.

Ofer said:
Is [Query - Catalog Append Table] its a table or a query, and is that the
full name?
Also if it is a query, is it a select query or append query?

--
I hope that helped
Good luck


jimswinder said:
nope...now I have
Select * From [Query - Catalog Append Table] Where BasicCategory =
Forms![Query - Catalog Append Table]![ BasicCategory].column(1)

still get the same error on trying to save...i also tried putting brackets
around BasicCategory so it looked like this:
Select * From [Query - Catalog Append Table] Where [BasicCategory] =
Forms![Query - Catalog Append Table]![ BasicCategory].column(1)

but got error message tha way too

Ofer said:
If that the name of the table, you need to close it with [], when the name
split into few words, you need to close it with []

Select * From [Query - Catalog Append Table] Where BasicCategory =
Forms![Query - Catalog Append Table]![BasicCategory].column(1)

--
I hope that helped
Good luck


:

so now I have the following:
Select * From Query - Catalog Append Table Where BasicCategory =
Forms![Query - Catalog Append Table]![ BasicCategory].column(1)

it still won't even let me save...get the same error message
"the syntax of the subquery in this expression is incorrect" Check the
subquerys syntax and enclose the subquery with parentheses.


:

You need to change the name of the table and the fields to the one you have.
TableName = The name of your table
FieldName = the name of the field in the above table that you need to
filter on

--
I hope that helped
Good luck


:

I get an error message "the syntax of the subquery in this expression is
incorrect".

Perhaps I did not put in all the right firld names. I have the following:

Select * From TableName Where FieldName = Forms![ Query - Catalog Append
Table]![ BasicCategory].column(1)

:

Try this

Select * From TableName Where FieldName = Forms![FormName]![ComboName]

Now, if you try to filter on the second column in a combo, use this

Select * From TableName Where FieldName =
Forms![FormName]![ComboName].column(1)

The column number start from 0, the first column doesnt need to be specify
--
I hope that helped
Good luck


:

How do you have a query use one of the values in a drop down list? When I
select one of the values, it just returns everything...not just the value in
the Combo box.
 
D

Douglas J Steele

Forms![Query - Catalog Append Table]![ BasicCategory] is looking for a
combobox named BasicCategory on a form named Query - Catalog Append Table.
(BTW, note that you've got a space in [ BasicCategory]: that's probably an
error!)

What exactly are you trying to do: filter the records returned on a form
(where the form gets its data from [Query - Catalog Append Table])? If so,
then what you want is:

Me.Filter = "BasicCategory = " & Me!BasicCategory.Column(1)
Me.FilterOn = True

if BasicCategory is numeric, or

Me.Filter = "BasicCategory = " & Chr$(34) & Me!BasicCategory.Column(1) &
Chr$(34)
Me.FilterOn = True

if it's text

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


jimswinder said:
[Query - Catalog Append Table] is a select query which queries a table
(Catalog Append Table) that has been appeneded.

Ofer said:
Is [Query - Catalog Append Table] its a table or a query, and is that the
full name?
Also if it is a query, is it a select query or append query?

--
I hope that helped
Good luck


jimswinder said:
nope...now I have
Select * From [Query - Catalog Append Table] Where BasicCategory =
Forms![Query - Catalog Append Table]![ BasicCategory].column(1)

still get the same error on trying to save...i also tried putting brackets
around BasicCategory so it looked like this:
Select * From [Query - Catalog Append Table] Where [BasicCategory] =
Forms![Query - Catalog Append Table]![ BasicCategory].column(1)

but got error message tha way too

:

If that the name of the table, you need to close it with [], when the name
split into few words, you need to close it with []

Select * From [Query - Catalog Append Table] Where BasicCategory =
Forms![Query - Catalog Append Table]![BasicCategory].column(1)

--
I hope that helped
Good luck


:

so now I have the following:
Select * From Query - Catalog Append Table Where BasicCategory =
Forms![Query - Catalog Append Table]![ BasicCategory].column(1)

it still won't even let me save...get the same error message
"the syntax of the subquery in this expression is incorrect" Check the
subquerys syntax and enclose the subquery with parentheses.


:

You need to change the name of the table and the fields to the one you have.
TableName = The name of your table
FieldName = the name of the field in the above table that you need to
filter on

--
I hope that helped
Good luck


:

I get an error message "the syntax of the subquery in this expression is
incorrect".

Perhaps I did not put in all the right firld names. I have the following:

Select * From TableName Where FieldName = Forms![ Query - Catalog Append
Table]![ BasicCategory].column(1)

:

Try this

Select * From TableName Where FieldName = Forms![FormName]![ComboName]

Now, if you try to filter on the second column in a combo, use this

Select * From TableName Where FieldName =
Forms![FormName]![ComboName].column(1)

The column number start from 0, the first column doesnt need to be specify
--
I hope that helped
Good luck


:

How do you have a query use one of the values in a drop down list? When I
select one of the values, it just returns everything...not just the value in
the Combo box.
 

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