Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box in Parameter Query?

Status
Not open for further replies.

hairwormman

Programmer
Dec 9, 2003
22
0
0
US
I am running a query to limit a data set; pretend for a moment it is to limit the data to entries from certain states. When I do this, a "Enter Parameter Value Dialog Box" appears, within which you specify your choice by manually typing it (say Arizona). This works well, but...Is it possible to make this dialog box a combo box, showing all of the states for which there is data in the database? In my case the states are
Thanks for any suggestions!!
 
create a form with combo box and a command button

EX

Form name : Form1
Comboname : combo0
query name : query1

now

the combo0 is bound to your "state table"


now place a command button the will run query1

go back to query1 and put this in the parameter section and the criteria with the parameter:

forms!form1!combo0

then run the form and voila you have a drop down menu driven parameter query

 
now technically you should but []'s around the names:

[forms]![form1]![combo0]

don't forget to delete off you old parameter. the above code replaces the parameter.

If you have multiple parameters, just create multiple combo box's

[forms]![form1]![combo0] <---states

[forms]![form1]![combo1] <---countries
 
Thanks for the suggestions. I have tried this, and the query will not return any data. For some reason the criteria section in the query will not read what is in the combo0 box. So, when I push the command button, the query runs without problems BUT it returns without any data. Thinking that there might be something wrong with my database (a setting I don't know about), I constructed a brand new db; the menu driven parameter query also fails here. Any other suggestions would be greatly appreciated.
Thanks!!!!
 
Check your data types. I created a sample database to test this and it worked flawlessly.

Make sure there are no leading or trailing spaces.

Since the query runs and pulls back nothing, it seems that your parameters are not matching the data in the columns. This is often caused by leading and trailing spaces, data types, and extra characters.

If the query runs then the parameter most likely is being sent to the query, it just may not be matching.

To find out the problem try using only 1 parameter at a time. You may want to insert a msgBox to output the parameter being passed to the query. This may tell you what was picked and what was being passed. You may be passing a blank even though you are picking something which would be a problem with your combo box.

Test each parameter and go from there. Do it one at a time to narrow down the problem code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top