Pull down (or filter) my report

  • Thread starter Thread starter chmorell
  • Start date Start date
C

chmorell

I have a report that generates information from different lawyers. I
don't wish to print out every single lawyer, or filter (SQL Query) a
certain criteira, is there a way that you can open a report and have a
pop up promt asking for a filter ?
 
The pop up is do-able via what is called a query parameter prompt -
but that means you would have to know the EXACT spelling of the lawyer
name, so it's not the recommended solution.

To do that - type something like [Enter the lawyer name] in the
section where you would typically manually modify the query (criteria
row below the lawyer name column in the query). Putting a question in
square brackets causes a pop up box to appear and whatever the user
types there would take the place of the question.

Better way is to print your report from a form that has a combo box on
it.

The combo box will list the different lawyers - so you pick which one
you want.
Add a where clause to the code on the print button to filter the
report by the combo box.

For example - if your report name is rptAttyData, your combo box is
called cboSharks, and your lawyer name field is called LawyerName -
the code for the print button would read:

DoCmd.OpenReport rptAttyData, acPreview, , "LawyerName = '" &
cboSharks & "'"

(In the alternative - set the lawyer name field criteria in the
underlying report query to be equal to the combo box on your form.
Easiest way to do that is to use the expression builder in the
criteria clause - which allows you to pretty much point and click your
way to a formula that references the form.)

Cindy
 
I have a report that generates information from different lawyers. I
don't wish to print out every single lawyer, or filter (SQL Query) a
certain criteira, is there a way that you can open a report and have a
pop up promt asking for a filter ?

You'll need to use a form to do this.

Let's assume it is a LawyerID number you need as criteria.

Make a new unbound form.
Add a combo box that will show the LawyerID field as well as the
LawyerName field.
Set the Combo Column Count property to 2.
If LawyerID is the first column, set the Column Width property to:
0";1"

Make sure the Combo Box Bound Column is the
LawyerID field.

Add a command button to the form.
Code the button's Click event:
Me.Visible = False
Name this form "ParamForm"

Code the Report's Record Source (a Query) LawyerID field's criteria
line:
forms!ParamForm!ComboBoxName

Code the Report's Open Event:
DoCmd.OpenForm "ParamForm" , , , , , acDialog

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

Run the Report.
The report will open the form.

Find the Lawyer in the combo box.
Click the command button.

The Report will display just those records selected.
When the Report closes it will close the form.
 

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