Results 1 to 5 of 5
  1. #1
    ahightower is offline Novice
    Windows Vista Access 2007
    Join Date
    Jan 2009
    Posts
    8

    Apply Filter 2 criteria not applying

    I am using a spilt view form and I am apply two different criteria to the data, one is based on a date range and the other is items selected in a multi select list box.

    When I separate each critera and run them separte they work, and when I put them together it actually works but just does not apply the filter. In order to actually apply the filter I have to select one of the drop down boxes (Where I see what I wanted filtered) then click ok and it filters correctly. So bascially my filter criteria that I input is in the drop down check boxes properly checked, it just doesn't automatically update.

    Below is my code, please help.

    Private Sub Command90_Click()

    Dim Criteria As String


    Dim i As Variant
    ' Build criteria string from selected items in list box.
    Criteria = ""
    For Each i In Me![List85].ItemsSelected
    If Criteria <> "" Then
    Criteria = Criteria & " OR "
    End If
    Criteria = Criteria & "[Line]='" _
    & Me![List85].ItemData(i) & "'"
    Next i
    ' Filter the form using selected items in the list box.


    Me.Filter = "[Date Production] Between " & CLng([Forms]![Start Screen]![StartDate]) & " And " & CLng([Forms]![Start Screen]![EndDate]) & " And " & Criteria


    Me.FilterOn = True

    End Sub

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    If you apply a filter you'll probably have to a run a requery on your data

    me.requery would update the form

    me.itemname.requery would update a particular control (list box, combo box, etc)

  3. #3
    ahightower is offline Novice
    Windows Vista Access 2007
    Join Date
    Jan 2009
    Posts
    8
    I have tried that it still doesn't work!

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Try with parens:
    & " And (" & Criteria & ")"

    With FilterOn should not need Requery, that's how my code works.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    ahightower is offline Novice
    Windows Vista Access 2007
    Join Date
    Jan 2009
    Posts
    8
    That did it! Thanks!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Option button to apply filter
    By catguy in forum Programming
    Replies: 4
    Last Post: 06-23-2011, 12:10 PM
  2. Replies: 2
    Last Post: 05-09-2011, 06:45 PM
  3. Access Reports - Applying a subform filter
    By AMCUser in forum Queries
    Replies: 13
    Last Post: 06-25-2010, 07:32 PM
  4. Apply filter command
    By miziri in forum Forms
    Replies: 6
    Last Post: 01-21-2010, 02:22 AM
  5. Applying a filter to a combo box
    By bugchaser in forum Programming
    Replies: 1
    Last Post: 02-20-2009, 02:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums