To filter records on a form.

  • Works on a sub form
  • DoCmd.applyfilter on a subform (DOES NOT WORK)


Filter using a STRING value

  • Me.Filter = "[COMPANY] = '" & StrCoSearch & "'"
  • Me.Filter = "[Rpt By]='" & StrUserSearch & "' And [COMPANY]='" & StrCoSearch & "'"


Filter using a FIXED value

  • Me.Filter = "[Status] = '6-HELP'"
  • Me.Filter = "[Status] <> '3-CLOSED'"       '(NOT LIKE a Value)


Filter using a INTEGER (NUMBER) value

        Example    

        

        Dim IntValueYR As Integer


        If IsNull([Filter_Year]) Then Exit Sub        'If the form field is NULL, then just exit the Sub Routine ELSE carry on

    

        IntValueYR = [Filter_Year]                        'Sets IntValueTR to a value on the form, in this case [Filter_Year]

    

        Me.Filter = "Yr =" & IntValueYR            ' Sets the filter to where the field on the form YR is = to IntValueYR 

        Me.FilterOn = True                                'Applies the filter






ME.FILTER


How to Handle Null values with filters

Remove Filters Problem

Help Links