Filter by form

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I would like to make a filter for a continuous form.
The filter should be a combo box with the following values:

All
Empty
Not Empty

(something like in Excel filter)

Is it possible to make it in Access?
 
Assuming you wish to apply this on a field named MyField, use the
AfterUpdate event of the combo to apply or remove the form's filter:

Private Sub cboFilter_AfterUpdate()
If Me.Dirty Then
Me.Dirty = False
End If

Select Case Me.cboFilter.Value
Case "All"
Me.FilterOn = False

Case "Empty"
Me.Filter = "[MyField] Is Null"
Me.FilterOn = True

Case "Not Empty"
Me.Filter = "[MyField] Is Not Null"
Me.FilterOn = True

Case Else
Msgbox "Huh?"
End If
End Sub
 
Back
Top