Results 1 to 2 of 2
  1. #1
    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 "
    End If

    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
    End If

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    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" something
    strWhere = & " and acolumn = 'blah'"
    ...and so on
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts