Using drop down box to activate report

  • Thread starter Thread starter Matthew Ellis
  • Start date Start date
M

Matthew Ellis

I am trying to use a pop up form with a combo box that,
when an item is selected from the list, it opens a report,
which is based on a query. I want to use the item selected
in the combo box to be used as criteria in the query. I
can do this when I am just running the query, but when I
try to run the report this way it will either return all
records on the report or it will return no records at all.
I am using the following criteria in the query:

[Forms]![reportusersearch]![Combo0]

and the code behind the "on change" event on the combo is:

Private Sub Combo0_Change()
Me.Combo0 = ""
DoCmd.OpenReport "rptcompinfouser", acViewPreview

The report runs off of the query: qrycompinfobyuser

Any help is appreciated. (By the way, the naming
conventions used are not mine, this is an inherited
database)
Thanks in advance.
Matt Ellis
 
Is the form open when you run the report? You must have the form open so
that the query can read the value from the form.
 
Yes, the form is open first and then when I select the
name from the combo box it opens the report.
-----Original Message-----
Is the form open when you run the report? You must have the form open so
that the query can read the value from the form.

--

Ken Snell
<MS ACCESS MVP>

I am trying to use a pop up form with a combo box that,
when an item is selected from the list, it opens a report,
which is based on a query. I want to use the item selected
in the combo box to be used as criteria in the query. I
can do this when I am just running the query, but when I
try to run the report this way it will either return all
records on the report or it will return no records at all.
I am using the following criteria in the query:

[Forms]![reportusersearch]![Combo0]

and the code behind the "on change" event on the combo is:

Private Sub Combo0_Change()
Me.Combo0 = ""
DoCmd.OpenReport "rptcompinfouser", acViewPreview

The report runs off of the query: qrycompinfobyuser

Any help is appreciated. (By the way, the naming
conventions used are not mine, this is an inherited
database)
Thanks in advance.
Matt Ellis


.
 
This is the code that's running on your combo box?

Private Sub Combo0_Change()
Me.Combo0 = ""
DoCmd.OpenReport "rptcompinfouser", acViewPreview


First, use the AfterUpdate event, and second don't change the value of the
combo box in the code:

Private Sub Combo0_AfterUpdate()
DoCmd.OpenReport "rptcompinfouser", acViewPreview
End Sub

Also, may I suggest that you use a command button on the form to open the
report instead of using one of the combo box's events?
--

Ken Snell
<MS ACCESS MVP>


Yes, the form is open first and then when I select the
name from the combo box it opens the report.
-----Original Message-----
Is the form open when you run the report? You must have the form open so
that the query can read the value from the form.

--

Ken Snell
<MS ACCESS MVP>

I am trying to use a pop up form with a combo box that,
when an item is selected from the list, it opens a report,
which is based on a query. I want to use the item selected
in the combo box to be used as criteria in the query. I
can do this when I am just running the query, but when I
try to run the report this way it will either return all
records on the report or it will return no records at all.
I am using the following criteria in the query:

[Forms]![reportusersearch]![Combo0]

and the code behind the "on change" event on the combo is:

Private Sub Combo0_Change()
Me.Combo0 = ""
DoCmd.OpenReport "rptcompinfouser", acViewPreview

The report runs off of the query: qrycompinfobyuser

Any help is appreciated. (By the way, the naming
conventions used are not mine, this is an inherited
database)
Thanks in advance.
Matt Ellis


.
 

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