Passing Form value to query

D

Drew

I have looked around and can't find any solution that fits my needs, maybe
someone can help. I have a query for a report that looks like this,

SELECT *
FROM table
WHERE criteria = CAT

When this query is run, it asks for CAT, which if you type a category in
correctly, it works. The problem is that some of the Categories are rather
long and I would like to present this in a dropdown box. The categories are
kept in a table, CatID and Category.

How can I pass the CatID from the dropdown to the query?

Thanks,
Drew
 
G

Guest

hi,
assuming you are doing this from a button....
In the query catagory field's criteria pane put this
[forms]![yourform]![Combobox1]
but i would qualify it also with this before the query runs
if isnull(me.combobox1) then
Msgbox("make a selection in the combobox")
exit sub
end if
this way the query wont run unless there is something in
the combobox.
 
D

Drew

That did it...

Thanks!
Drew

hi,
assuming you are doing this from a button....
In the query catagory field's criteria pane put this
[forms]![yourform]![Combobox1]
but i would qualify it also with this before the query runs
if isnull(me.combobox1) then
Msgbox("make a selection in the combobox")
exit sub
end if
this way the query wont run unless there is something in
the combobox.
-----Original Message-----
I have looked around and can't find any solution that fits my needs, maybe
someone can help. I have a query for a report that looks like this,

SELECT *
FROM table
WHERE criteria = CAT

When this query is run, it asks for CAT, which if you type a category in
correctly, it works. The problem is that some of the Categories are rather
long and I would like to present this in a dropdown box. The categories are
kept in a table, CatID and Category.

How can I pass the CatID from the dropdown to the query?

Thanks,
Drew


.
 
G

Guest

glad to help
-----Original Message-----
That did it...

Thanks!
Drew

hi,
assuming you are doing this from a button....
In the query catagory field's criteria pane put this
[forms]![yourform]![Combobox1]
but i would qualify it also with this before the query runs
if isnull(me.combobox1) then
Msgbox("make a selection in the combobox")
exit sub
end if
this way the query wont run unless there is something in
the combobox.
-----Original Message-----
I have looked around and can't find any solution that fits my needs, maybe
someone can help. I have a query for a report that
looks
like this,
SELECT *
FROM table
WHERE criteria = CAT

When this query is run, it asks for CAT, which if you type a category in
correctly, it works. The problem is that some of the Categories are rather
long and I would like to present this in a dropdown box. The categories are
kept in a table, CatID and Category.

How can I pass the CatID from the dropdown to the query?

Thanks,
Drew


.


.
 
Top