Code Examples

Filter Excluding Selection

acCmdFilterExcludingSelection

Filters the data on a form by excluding everthing that matches the last selected field. Place the code behind a command button called cmdFilterXSelect.

' ***************** Code Start *******************
Code by Terry Wickenden

Private Sub cmdFilterXSelect_Click()
   On Error Goto ErrHandler
    Screen.PreviousControl.SetFocus
    DoCmd.RunCommand acCmdFilterExcludingSelection
    Exit Sub
ErrHandler:
    Select Case Err.Number
        Case 2046 'Filter not available at moment
            MsgBox "Command not available"
        Case Else
            MsgBox Err.Number & vbCrLf & Err.Description
    End Select
End Sub

' *****************  Code End  *******************

© 1998 - 2011 Terry Wickenden TKW Design Site developed maintained and hosted by TKW Design. This site is best viewed at 1024 x 768. Optimised for Firefox.