Hi,
I currently have a query called qryDetails, and form called
frmWhatDates and a report rptDetails.
The form frmWhatDates has 2 txt boxes StartDate and EndDate and also a
combo box cmbCatergory. This allows users to select the criteria for
the report to be based upon. Only problem is Iam unsure of the code to
put in the report, query and form for this to work as the code i got
form the microsoft website doesnt seem to work.
Fiona
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 CategoryID number you need as criteria.
Next, make a new unbound form.
Add a combo box that will show the CategoryID field as well as the
Category Name field (you can use the Combo Box wizard to do so).
Set the Combo box's Column Count property to 2.
Hide the CategoryID field by setting the Combo box's ColumnWidth
property to 0";1"
Make sure the Combo Box Bound Column is the
CategoryID field.
Name this Combo Box "cboFindCategory".
Add 2 text controls to the form.
Set their Format property to any valid date format.
Name one control "StartDate". Name the other control "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 CategoryID field
criteria line write:
forms!ParamForm!cboFindCategory
As criteria on the query's Date field, write:
Between forms!ParamForm!StartDate and forms!ParamForm!EndDate
Open the Report in design view.
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 Category Name in the combo box.
Enter the Starting date and the Ending dates wanted.
Click the command button.
The Report will display just those records selected within the time
span entered.
When the Report closes it will close the form.