Combo box in Query criteria

J

JJ682

I want to display the results of a query in a form based on criteria. I want
the criteria to be chosen from a combo box to lessen the chance for error. I
have created a table with the list, created a form with a combo box that
displays the list. When I use the Build function in the query criteria line
and to attach to the combo box, I get- Forms!NameofForm!NameofComboBox as
the prompt and still have to enter the criteria. Please help.
 
G

Golfinray

Go into the onclick event of the combo box and type:
DoCmd.openreport "your report name", acviewpreview

Also, put brackets([]) around your query statement like this
[forms]![name of form]![name of combo box]
Also remember that in the query, you put the form name, in the event you put
the report name.
 
K

KARL DEWEY

You have to replace NameofForm with your form name and NameofComboBox with
the name of the combo box in the query criteria. Open the query in design
view to perform the edit on the criteria. The names MUST be extact.
 
J

JJ682

In the onclick event of the combo box, I typed what you had. But I have a
question, I don't have the query in a report, it is in a form. So would it be
openform"myformname" ? And you type that in the line, not in SQL?

I had the [] around the query statement.


Golfinray said:
Go into the onclick event of the combo box and type:
DoCmd.openreport "your report name", acviewpreview

Also, put brackets([]) around your query statement like this
[forms]![name of form]![name of combo box]
Also remember that in the query, you put the form name, in the event you put
the report name.

JJ682 said:
I want to display the results of a query in a form based on criteria. I want
the criteria to be chosen from a combo box to lessen the chance for error. I
have created a table with the list, created a form with a combo box that
displays the list. When I use the Build function in the query criteria line
and to attach to the combo box, I get- Forms!NameofForm!NameofComboBox as
the prompt and still have to enter the criteria. Please help.
 
J

JJ682

Karl, sorry I wasn't clear. I just used the generic NameofComboBox and
NameofForm as an example. I did have the exact name. I used the Build to link
to it exactly. Any other ideas?
 

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