none
MS Access Code

    Question

  • Hi All,

    I having problem with the Code for MS Access filter between 2 dates.

    It unable to filter but the clear button work

    The filed name is Opened Date: 

    Private Sub Command37_Click()
    Call Search
    End Sub
    Sub Search()
    Dim strCriteria, task As String

    Me.Refresh
    If IsNull(Me.OpenFrom) Or IsNull(Me.OpenTo) Then
        MsgBox "Please enter the date range", vbInformation, "Date Range Required"
        Me.OpenFrom.SetFocus
    Else
        strCriteria = "(Opened Date <= #" & Me.OpenFrom & "# And Opened Date => #" & Me.OpenTo & "#)"
        task = "select * from Issues where (" & strCriteria & ") order by [Opened Date]"
        DoCmd.ApplyFilter task
            

    End If


    End Sub

    Private Sub Command39_Click()
    Dim task As String
        Me.OpenFrom = Null
        Me.OpenTo = ""
        task = "select * from Issues where id is null"
        DoCmd.ApplyFilter task
          


    End Sub

    Monday, August 8, 2016 2:06 AM

Answers