Filter between 2 dates

D

Dave

I need the code for a button on my form that will filter the form for
records that have TWO(2) date fields by a user entered date range. (BOTH
date fields must be in the entered date range)

This is the start I got just trying to filter greated the the first field
and it does not work.



Private Sub cmdFilter_Click()
On Error GoTo Err_cmdFilter_Click

Dim stDocName As String

DoCmd.ShowAllRecords
Me.Filter = [#txtStartDate#] > [#SentenceStartDate#]
Me.FilterOn = True
'SendKeys "{F2}"

Exit_cmdFilter_Click:
Exit Sub

Err_cmdFilter_Click:
MsgBox Err.Description
Resume Exit_cmdFilter_Click

End Sub

Any help here will be appreciated.

Thanks in advance

dave
 
A

Arvin Meyer [MVP]

Try:

Me.Filter = "[MyDateField] Between #" & Format$(Me![StartDate], _
"mm/dd/yyyy") & "# And #" & Format$(Me![EndDate], "mm/dd/yyyy") & "#"
 

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