Problem with Combo Boxes using Filter By Form and sending to Repor

S

sjSQW

I have created a database that stores reviews of various documents (articles,
books, Government reports, etc). I have created a form for entering the data.
And I have created a form for searching the records.

As part of the search feature of the database, I want to be able to use the
Filter By Form feature of Access to select records and then print those
records using Access's reports feature. Using Visual Basic code
(DoCmd.OpenReport...) that I have found online I have set this up and for the
most part it works.

The remaining problem I have seems to be with the Combo Boxes I have in the
form. When I select records using Filter By Form on the basis of a combo box
and then use the command button that sends the filtered records to the
report, a dialogue box appears asking me to 'Enter Paramater Value' for that
combo box. If I type in the filter data, it works, but I really don't want to
have to do this.

Can anyone help?
 
B

BruceM

It is best to post the actual code. DoCmd.OpenReport could contain any
number of further options. One of these is the Where argument. One
possibility may be to select something from the combo box, then use that
value to limit the report records:
DoCmd.OpenReport "ReportName", , ,"[SomeField] = " & Me.ComboBoxName

If you want to filter the form before you print the report you can use
Filter By Form as you are doing, or you can build a filter string or the
record source SQL. However, there is no need to filter the form in order to
get a specific group of records in the report. In other words, filter the
form if you want, but it is not needed to generate a subset of records for
the report.
 
S

sjSQW

The code is as follows:

Private Sub cmdOpenReport_Click()
If Me.Filter = "" Then
MsgBox "Apply a filter to the form first."
Else
DoCmd.OpenReport "rptProForma", acViewPreview, , Me.Filter
End If
End Sub

This sends the filtered records to the report.

Note that the form contains lots of controls (or whatever the right term is
for them), only a few of which are Combo Boxes. I need to be able to filter
using any or all of the controls in the form.

When I Filter By Form without using one of the Combo Boxes (using a Text
Box, for example) and then run the command above, it works fine. The problem
seems to be only when I use one of the Combo Boxes.

Any thoughts?

Stuart


BruceM said:
It is best to post the actual code. DoCmd.OpenReport could contain any
number of further options. One of these is the Where argument. One
possibility may be to select something from the combo box, then use that
value to limit the report records:
DoCmd.OpenReport "ReportName", , ,"[SomeField] = " & Me.ComboBoxName

If you want to filter the form before you print the report you can use
Filter By Form as you are doing, or you can build a filter string or the
record source SQL. However, there is no need to filter the form in order to
get a specific group of records in the report. In other words, filter the
form if you want, but it is not needed to generate a subset of records for
the report.

sjSQW said:
I have created a database that stores reviews of various documents
(articles,
books, Government reports, etc). I have created a form for entering the
data.
And I have created a form for searching the records.

As part of the search feature of the database, I want to be able to use
the
Filter By Form feature of Access to select records and then print those
records using Access's reports feature. Using Visual Basic code
(DoCmd.OpenReport...) that I have found online I have set this up and for
the
most part it works.

The remaining problem I have seems to be with the Combo Boxes I have in
the
form. When I select records using Filter By Form on the basis of a combo
box
and then use the command button that sends the filtered records to the
report, a dialogue box appears asking me to 'Enter Paramater Value' for
that
combo box. If I type in the filter data, it works, but I really don't want
to
have to do this.

Can anyone help?
 

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