06-26-11, 17:27 #1Registered User
- Join Date
- Aug 2010
Unanswered: MS Acces Form Date Filter Help Needed
I would like to filter my form and show records for the current date. Right now I have an unbound text box on the form with its control source set using the date() function. I can filter the same form if I use the < or > operator but not =. Please help if you can. The result I am getting is the form is filtering all records. Thanks
Dim strWhere As String
Dim lngLen As Long
Const conJetDate = "\#mm\/dd\/yyyy\#"
Dim strDate As String
If Not IsNull(Me.txtDate) Then
strWhere = strWhere & "([apptDate] = " & Format(Me.txtDate, conJetDate) & ") AND "
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn = True
06-26-11, 18:41 #2Jaded Developer
Provided Answers: 59
- Join Date
- Nov 2004
- out on a limb
bear in mind a format isn't the same as the underlying value
I'd suggest you try converting the value of the text box to a date value
strWhere = strWhere & "[apptDate] = " & cdate(txtDate) & " AND "
incidentally a trick you can consider usign when building a where clause is
strWhere = "where 1=1"
strWhere = & " and acolumn = 'blah'"
...and so onI'd rather be riding on the Tiger 800 or the Norton