I am fairly new to using Access and here's what I want to do:
I want to create a form that allows the user to select a leader, enter a date
and receive data back for only their employees in a report. I know it's
possible, but I don't know how to get started. I have queries created with
the data needed. I just need to be able to select certain records,
preferably by a drop-down.
Any help is appreciated!
You'll need to use a form to do this.
First, create a query that will display the fields you wish to show in
the report.
Second, create a report, using the query as it's record source, that
shows the data you wish to display for ALL records.
Let's assume it is a EmployeeID number you need as criteria, as well
as a starting and ending date range.
Next, make a new unbound form.
Add a combo box that will show the EmployeeID field as well as the
Employee Name field (you can use the Combo Box wizard to do so).
Set the Combo box's Column Count property to 2.
Hide the EmployeeID field by setting the Combo box's ColumnWidths
property to 0";1"
Make sure the Combo Box Bound Column is the
EmployeeID column.
Name this Combo Box "cboFindName".
Add 2 unbound text controls to the form.
Set their Format property to any valid date format.
Name one "StartDate".
Name the other "EndDate".
Add a command button to the form.
Code the button's Click event:
Me.Visible = False
Name this form "ParamForm"
Go back to the query. As criteria, on the Query's EmployeeID field
criteria line write:
forms!ParamForm!cboFindName
As Criteria on the DateField, write:
Between forms!ParamForm!StartDate and forms!ParamForm!EndDate
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 Employee Name in the combo box.
Enter the starting and ending dates.
Click the command button.
The Report will display just those records selected.
When the Report closes it will close the form.