I want to filter my report by specific dates

cliff7376

Registered User.
Local time
Today, 08:15
Joined
Oct 10, 2001
Messages
107
I have a report for our calibrations for our company and this person would like to pull up a report and have the report ask him what dates he wants to filter by. I don't know what to put in the query to have the report due that. Can anyone help me please?
 
Here is a sub that uses two text boxes on a form and a command button. You enter the begin date and the end date and press the button. The report will then be opened with the data between the dates. I also added a way to stop the process and prompt the user if they try to open a report without putting in the date.

Dim bProcOk As Boolean
bProcOk = True

' The following IF Then series checks for null values in
' the stated txtbox. If a null is found the error message
' is displayed and the focus is sent back to form control

If IsNull(Me.txtBeginDate) Then

MsgBox "You must provide a beginning date!", vbExclamation, "Error"
txtBeginDate.SetFocus
bProcOk = False

Else

If IsNull(Me.txtEndDate) Then
MsgBox "You must provide a ending date!", vbExclamation, "Error"
txtEndDate.SetFocus
bProcOk = False

End If
End If

If bProcOk Then ' If the above IF Thens are satisfied
' the following command is carried out

DoCmd.OpenReport "EmpContactLog", acPreview, , _
"[date]>=#" & Me![txtBeginDate] & "# And [date]<= #" & _
Me![txtEndDate] & "#"
' Opens the report based on the begin and end date

End If

End Sub
 
thank you very much i was trying it everyway i could think of. worked great. thanks alot.
 
Hi. You might also want to check my answer to Devx's question right after yours was posted here. Just another way to do it.

Russ
 

Users who are viewing this thread

Back
Top Bottom