Select Thing in Report

A

Anthony

How can you set up when you run a report to only pick a certain information.
I have a table that has a drop down menu of locations, I would like to run a
report and when you go to run it it asks you what location you would like to
pick. If you could please reply when you get a chance. Thanks.
 
F

fredg

How can you set up when you run a report to only pick a certain information.
I have a table that has a drop down menu of locations, I would like to run a
report and when you go to run it it asks you what location you would like to
pick. If you could please reply when you get a chance. Thanks.

Let's assume you wish to filter the report so that only records
pertaining to a particular company are shown. Change the field names
as needed, but the process is the same.

Create an unbound form.
Add a combo box.
Set the Row Source of the combo box to include the
CompanyID field and the Company Name.
Set it's Bound column to 1.
Set it's Column Count property to 2.
Set the Column Width property to 0";1"
Name the Combo Box 'FindCompany'.

Add a Command Button to the form.
Code the button's click event as follows:

(Note: To write the code, in Form Design View select the command
button. Display the button's property sheet.
Click on the Event tab.
On the On Click line, write:

[Event Procedure]

Click on the little button with the 3 dots that appears on that line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those lines, write the following code.)

Me.Visible = False

Close the Code window.

Name this form 'ParamForm'.

In the Query that is the Report's Record Source [CompanyID] field
criteria line write:

forms!ParamForm!FindCompany

Next, code the Report's Open event:
(Using the same method as described above)

DoCmd.OpenForm "ParamForm", , , , , acDialog

Code the report's Close event:

DoCmd.Close acForm, "ParamForm"

When ready to run the report, open the report.
The form will open and wait for the selection of the Company.
Click the command button and then report will run.
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

Top