Results 1 to 8 of 8
  1. #1
    data808 is offline Noob
    Windows 7 32bit Access 2007
    Join Date
    Aug 2012
    Posts
    727

    How to do more than one filter at the same time?

    I have a split form that the datasheet is on the bottom. Then I have 5 unbound text boxes on the top of this split form, each with its own filter button and of course a clear filter button on the side. The problem is I can only use one filter at a time. Here is the code I am using behind the filter button for each of my unbound text boxes:

    Private Sub cmdFilterDateIssued_Click()

    Me.Filter = "[Date Issued:] Like '*" & Me.txtFilterDateIssued & "*'"
    Me.FilterOn = True
    Me.Requery

    End Sub

    Here is another one:

    Private Sub cmdFilterOpLicNum_Click()

    Me.Filter = "[Op Lic:] Like '*" & Me.txtFilterOpLicNum & "*'"
    Me.FilterOn = True
    Me.Requery

    End Sub

    How would I go about setting it up so I can first do a search on Date Issued? Then add on another search to narrow the results even further by doing the next search on the Operator Licenses?

    Any help is appreciated. Thanks.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I'd either have one button or no button. I'd have a function that tested each textbox and built a filter using any that were filled out. I'd call that function from the after update event of each textbox, or use a button if there were performance issues with the first. Building SQL in code is demonstrated in the sample db here:

    http://www.baldyweb.com/BuildSQL.htm

    You would tweak it to just build a filter.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    data808 is offline Noob
    Windows 7 32bit Access 2007
    Join Date
    Aug 2012
    Posts
    727
    Still a beginner in vba and don't know anything about sql. Would you have a template that I can just change the code to fit my situation?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Just that sample db.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Maybe this will also help http://allenbrowne.com/ser-62code.html
    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.

  6. #6
    data808 is offline Noob
    Windows 7 32bit Access 2007
    Join Date
    Aug 2012
    Posts
    727
    Hey June7,

    I think you sent this to me before and its making a little more sense now. Is this a split form that Allen Browne is using? The part I'm not to clear on is at the end on the before insert event when he talks about allowing additions. Does this mean that if its a frontend/backend database with multi users entering data, you will not be able to see new records being entered unless you refresh the page by closing the form and reopening it? Could you explain this Before Insert sub and what exactly its doing?

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I believe this code was written before split form was ever a feature in Access. Shouldn't make any difference.

    I've never noticed the BeforeInsert procedure. Did you explore the link Allen shows in the procedure comment?

    A form does not have to be closed and reopened to display new records, a Requery will do that.
    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.

  8. #8
    data808 is offline Noob
    Windows 7 32bit Access 2007
    Join Date
    Aug 2012
    Posts
    727
    Yeah I followed the link but it didn't make sense to me. Anyway, thanks for the info. I'll try it out and let you know how it goes.

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

Similar Threads

  1. Can you filter two subforms at the same time?
    By haggis999 in forum Forms
    Replies: 17
    Last Post: 12-30-2012, 04:06 AM
  2. Access Time Filter
    By djohnson09 in forum Access
    Replies: 1
    Last Post: 07-26-2012, 12:06 AM
  3. Filter not working the first time
    By NISMOJim in forum Programming
    Replies: 4
    Last Post: 07-07-2012, 06:38 PM
  4. Replies: 7
    Last Post: 08-04-2011, 07:49 PM
  5. Filter Report by Time
    By Tyork in forum Reports
    Replies: 4
    Last Post: 11-11-2010, 01:17 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