Passing Form value to query

  • Thread starter Thread starter Drew
  • Start date Start date
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
 
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.
 
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


.
 
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


.


.
 

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

Back
Top