Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Filter question (97)

    Filter question

    Here

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Filter question (97)

    Your filter has to be a string, and the expression you will return a boolean because it's not. Here's another method:
    <pre>
    Private Sub cmdFilter_Click()
    On Error GoTo Err_Filter_Click

    'remove any existing filter
    Me.FilterOn = False

    'add a filter
    Me.Filter = "Right([OrderDate],1)=" & Right(Me.txtOrderDate, 1)
    Me.FilterOn = True
    Exit_Filter_Click:
    Exit Sub

    Err_Filter_Click:
    MsgBox Err.Description
    Resume Exit_Filter_Click

    End Sub 'cmdFilter_Click()

    Private Sub cmdRemove_Click()
    Me.FilterOn = False
    Me.Filter = ""
    End Sub 'cmdRemove_Click() </pre>


    In this case, I set up a continuous form and decided I wanted to be able to filter the form based on the last digit of the year in the last OrderDate I clicked in. The filter expression can only contain a field name in the recordset (no "Me" allowed) and the value you want to apply. Actually, you can use more complicated filters, but you still can't use anything but the field names on the left side of the equations.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •