Create an empty form and open in design view.
Put two textboxes on the form. Put appropriate label names on the textboxes.
Right click on the first textbox and go down to the bottom of the list to Properties. The first tab is the list of Format Properties and the first item on the list is format. Change this to an appropriate date format. The standard is:
Short Date
Next click on the Data tab and go down to the Default Value property. Type in
Now()
This will set the date to todays date when the form opens.
Then go to the Other tab and change the Name property to
DateFrom
Do the same for the second text box except name it
DateTo
Then add a command button to the report. Use the wizard to indicate that you want to open the relevant report to show all records. (Don't forget to remove the Criteria from the Reports query that you are currently using to set the date range.
When the wizard closes go to the properties of the command button (right click). Go to the event tab and click on the button with the dots beside the On Click event.
The code should look something like this:
Private Sub Command1_Click()
Dim stDocName As String
stDocName = "Report Name"
DoCmd.OpenReport stDocName, acViewPreview
End Sub
You need to change it so it looks like this:
Private Sub Command1_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Report Name"
stLinkCriteria = "[DateField] BETWEEN " & Me.DateFrom & " AND " & Me.DateTo
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
End Sub
Close and save the form with an appropriate name. Set it so that this form now opens instead of the report when the user wants to view/print the report.
As before add a textbox to your report as described in previous post.
Could you tell me how or were do I set the parameters from the report, so the dates can be printed on the report.
Thank you very much
Jose