MS Access Code RRS feed

  • 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

    If IsNull(Me.OpenFrom) Or IsNull(Me.OpenTo) Then
        MsgBox "Please enter the date range", vbInformation, "Date Range Required"
        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