How do I use a combo box value in a query?

C

CSAngel

I am going crazy trying to get this to work - it seems so simple.

I have the following:
Table - MasterStatus
Form - Issues
Form - Main
On the Main form there is a combo box (cbType) and a button. When I press
the button I want the Issues form to populate with a list of items of the
type selected in the combo box.

I set up a Macro for the On click event of the button as follows:
Macro - OpenForm
Where - [MasterStatus].[Type] = [Forms]![Main].[cbType]

this doesn't work. Nothing is returned even though I have selected a type
that has several records.

PLEASE HELP!

Thanks.
 
C

CSAngel

It won't let me. It tells me Type could refer to more than one Table in my
FROM clause.

Ken Snell (MVP) said:
Change to this:

Where - [Type] = [Forms]![Main]![cbType]


--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/



CSAngel said:
I am going crazy trying to get this to work - it seems so simple.

I have the following:
Table - MasterStatus
Form - Issues
Form - Main
On the Main form there is a combo box (cbType) and a button. When I press
the button I want the Issues form to populate with a list of items of the
type selected in the combo box.

I set up a Macro for the On click event of the button as follows:
Macro - OpenForm
Where - [MasterStatus].[Type] = [Forms]![Main].[cbType]

this doesn't work. Nothing is returned even though I have selected a type
that has several records.

PLEASE HELP!

Thanks.
 
K

Ken Snell \(MVP\)

Post the SQL Statement of your query...let's see what the fields are.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


CSAngel said:
It won't let me. It tells me Type could refer to more than one Table in
my
FROM clause.

Ken Snell (MVP) said:
Change to this:

Where - [Type] = [Forms]![Main]![cbType]


--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/



CSAngel said:
I am going crazy trying to get this to work - it seems so simple.

I have the following:
Table - MasterStatus
Form - Issues
Form - Main
On the Main form there is a combo box (cbType) and a button. When I
press
the button I want the Issues form to populate with a list of items of
the
type selected in the combo box.

I set up a Macro for the On click event of the button as follows:
Macro - OpenForm
Where - [MasterStatus].[Type] = [Forms]![Main].[cbType]

this doesn't work. Nothing is returned even though I have selected a
type
that has several records.

PLEASE HELP!

Thanks.
 
C

CSAngel

The query is super simple:
SELECT IssuesRisks.*
FROM IssuesRisks;

(I changed the name) The table contains a bunch of Risks and Issues. I want
to use a combo box to choose to return one or the other (ie: Where
IssuesRisks.Type = "Issue")

I use the where clause in the macro to define which records to return. This
works fine if I hard code "Issue" or "Risk" OR if I use a text field
[txtType] - I only have an issue if I try to use a combo box [cbType]
instead. My guess is that my combo box is not returning "Issue"/"Risk" but
is returning some type of index instead?

The query is used by a bunch of other forms as well.

Thanks!


Ken Snell (MVP) said:
Post the SQL Statement of your query...let's see what the fields are.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


CSAngel said:
It won't let me. It tells me Type could refer to more than one Table in
my
FROM clause.

Ken Snell (MVP) said:
Change to this:

Where - [Type] = [Forms]![Main]![cbType]


--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/



I am going crazy trying to get this to work - it seems so simple.

I have the following:
Table - MasterStatus
Form - Issues
Form - Main
On the Main form there is a combo box (cbType) and a button. When I
press
the button I want the Issues form to populate with a list of items of
the
type selected in the combo box.

I set up a Macro for the On click event of the button as follows:
Macro - OpenForm
Where - [MasterStatus].[Type] = [Forms]![Main].[cbType]

this doesn't work. Nothing is returned even though I have selected a
type
that has several records.

PLEASE HELP!

Thanks.
 
C

CSAngel

Sorry, I should add that the query has been simplified since I got the error
below - I don't get that error any more - I just don't get any records.

Ken Snell (MVP) said:
Post the SQL Statement of your query...let's see what the fields are.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


CSAngel said:
It won't let me. It tells me Type could refer to more than one Table in
my
FROM clause.

Ken Snell (MVP) said:
Change to this:

Where - [Type] = [Forms]![Main]![cbType]


--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/



I am going crazy trying to get this to work - it seems so simple.

I have the following:
Table - MasterStatus
Form - Issues
Form - Main
On the Main form there is a combo box (cbType) and a button. When I
press
the button I want the Issues form to populate with a list of items of
the
type selected in the combo box.

I set up a Macro for the On click event of the button as follows:
Macro - OpenForm
Where - [MasterStatus].[Type] = [Forms]![Main].[cbType]

this doesn't work. Nothing is returned even though I have selected a
type
that has several records.

PLEASE HELP!

Thanks.
 
C

CSAngel

I'm using 2007.

CSAngel said:
Sorry, I should add that the query has been simplified since I got the error
below - I don't get that error any more - I just don't get any records.

Ken Snell (MVP) said:
Post the SQL Statement of your query...let's see what the fields are.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


CSAngel said:
It won't let me. It tells me Type could refer to more than one Table in
my
FROM clause.

:

Change to this:

Where - [Type] = [Forms]![Main]![cbType]


--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/



I am going crazy trying to get this to work - it seems so simple.

I have the following:
Table - MasterStatus
Form - Issues
Form - Main
On the Main form there is a combo box (cbType) and a button. When I
press
the button I want the Issues form to populate with a list of items of
the
type selected in the combo box.

I set up a Macro for the On click event of the button as follows:
Macro - OpenForm
Where - [MasterStatus].[Type] = [Forms]![Main].[cbType]

this doesn't work. Nothing is returned even though I have selected a
type
that has several records.

PLEASE HELP!

Thanks.
 
K

Ken Snell \(MVP\)

What is the datatype of the Type field in your table? What is an example of
the Type value that you're using, and which is not returning any records?
What is the RowSource query for the cbType combo box? What is the bound
column for this combo box?

Also, is the combo box cbType a combo box on a main form and not a subform?

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


CSAngel said:
Sorry, I should add that the query has been simplified since I got the
error
below - I don't get that error any more - I just don't get any records.

Ken Snell (MVP) said:
Post the SQL Statement of your query...let's see what the fields are.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


CSAngel said:
It won't let me. It tells me Type could refer to more than one Table
in
my
FROM clause.

:

Change to this:

Where - [Type] = [Forms]![Main]![cbType]


--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/



I am going crazy trying to get this to work - it seems so simple.

I have the following:
Table - MasterStatus
Form - Issues
Form - Main
On the Main form there is a combo box (cbType) and a button. When I
press
the button I want the Issues form to populate with a list of items
of
the
type selected in the combo box.

I set up a Macro for the On click event of the button as follows:
Macro - OpenForm
Where - [MasterStatus].[Type] = [Forms]![Main].[cbType]

this doesn't work. Nothing is returned even though I have selected
a
type
that has several records.

PLEASE HELP!

Thanks.
 

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