combo box for selecting criteria

S

Stella K.

Hi all,

I haven't used Access much and I'm learning as I go, but I
haven't found a solution to the following problem.

I want users to be able to select the parameters for a
query-based report from a drop-down list. I have created a
combo box on an unbound form, but when I enter the
following on the criteria line of the query

[Forms]![Form1]![ComboName]

the form does not appear when I run the query, just a
standard prompt box with same text. When I run the report,
the form appears, I can select an entry from the combo
box, but it does not set the parameters for the query -- I
just get #error as data. I've tried to use the .[Column]
expression (if that's the right term) but that produces
only errors with the parentheses.

Any advice? (I've crossposted in the queries group since
I'm not sure where the problem lies).

Thanks in advance.
 
F

Fredg

Stella,
You have a misconception of how this works.

You have to decide what you are going to use the query for.
Is it to view the data in the query, or is the query the
record source for a report.

1) If it is to view the data directly in the query, then add
a command button to the form.
Code it's click event:
DoCmd.OpenQuery "QueryName"

When you wish to view the query, open the form.
Select the parameters in the combo box.
Click the command button.
The query will open and display it's data.

2) However, if the query is to be the record source for a report,
then code the form's command button:
Me.Visible = False

Code the report's Open event:
DoCmd.OpenForm "FormName", , , , , acDialog

Code the Report's Close event:
DoCmd.Close acForm, "FormName"

Now, when you wish to run the report, open the report.
The report opens the form. When you enter the parameter
and click the form command button, the report will run.
When you close the report, it will close the form.
You never see the query.

By the way, I'm sure you are aware that in the coding above,
as well as in your criteria line ([Forms]![Form1]![ComboName]),
you must substitute your actual field, form, query, and report names
for the generic ones above.

Hope this helps.
 

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