How to clear filter to display all data in ms access 2007?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • HiGu
    New Member
    • Feb 2012
    • 99

    How to clear filter to display all data in ms access 2007?

    I have a combobox that filters data on the form in the afterupdate event.
    Following is the query I have been trying to use to filter data.This code filters data effectively but the problem that I am facing is that when I select "<ALL>" from the combobox no data is displayed.What could be wrong?How can I display all the data of the form on selection of "<ALL>"
    Code:
    Dim strCriteria As String
       strCriteria = "[Jobno]='" & cboPMNO & "'"
          Set rst = Me.RecordsetClone
    If strCriteria = "<ALL>" Then
          Me.FilterOn = False
    ElseIf rst.NoMatch Then
          MsgBox "No entry found"
    Else
        Me.FilterOn = False
        Me.Filter = strCriteria
        Me.FilterOn = True
    End If
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Hi

    Shouldn't this
    Code:
    If strCriteria = "<ALL>" Then
    be this
    Code:
    If cboPMNO = "<ALL>" Then
    ??

    Also you hve not filtered the RecorsetClone before you tested for NoMatch !??


    MTB

    Comment

    • HiGu
      New Member
      • Feb 2012
      • 99

      #3
      That's one big point that I was missing.
      It shoud be cboPMNO..Thanks a lot.Instead of line#5 I am using this
      Code:
      Docmd.ShowAllRecords
      I am testing for NoMatch and then fiIltering,I think.I thought if I check for NoMatch before this then it's bound to have no match as <ALL> is not in the table.The condition for all records is not filteringI guess.

      Comment

      Working...