Results 1 to 4 of 4
  1. #1
    Stephenson is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Location
    North West
    Posts
    110

    Filter subform with multiple combo boxes and date ranges.

    Hello all,

    I'm new to the access game and loving learning it. I have however hit a bit of a wall in my DB. I've got a form named TimeCard that holds a subform named TimeCardSub. I'm trying to use this sub for two purposes. One for the data entry person to see what they're entering and the second to be able to search for Records.

    My issue is with the ability to create a search for the records. I have the combo boxes; cboSearchEmployee, cboSearchJob, and cboSearchService that I would like to use to filter down the subform, then be able to click on a certain row, bring it up to the form and edit it if needed. So far here is the code I'm using.

    Code:
    Private Sub cboSearchEmployee_AfterUpdate()
         If IsNull(Me.cboSearchEmployee) Then
       Me.cldTimeCard.Form.Filter = ""
       Me.cldTimeCard.Form.FilterOn = False
    Else
      Me.cldTimeCard.Form.Filter = "[EmployeeID]=" & Me.cboSearchEmployee
      Me.cldTimeCard.Form.FilterOn = True
    End If
       Exit Sub
    End Sub
    
    
    Private Sub cboSearchJob_AfterUpdate()
        If IsNull(Me.cboSearchJob) Then
       Me.cldTimeCard.Form.Filter = ""
    Me.cldTimeCard.Form.FilterOn = False
    Else
      Me.cldTimeCard.Form.Filter = "[JobID]=" & Me.cboSearchJob
      Me.cldTimeCard.Form.FilterOn = True
    End If
       Exit Sub
    End Sub
    
    
    Private Sub cboSearchService_AfterUpdate()
        If IsNull(Me.cboSearchService) Then
       Me.cldTimeCard.Form.Filter = ""
       Me.cldTimeCard.Form.FilterOn = False
    Else
      Me.cldTimeCard.Form.Filter = "[ServiceID]=" & Me.cboSearchService
      Me.cldTimeCard.Form.FilterOn = True
    End If
       Exit Sub
    End Sub
    The problem is that it will not filter down off of all the combo boxes together. I need a way to code this so that all the filters work together. Is there a way to change my code or a better way all together to get a search such as this to work? FYI I'm dumb when it comes to queries.

    On top of this I would like to add the ability to search for a date range. Say between two dates or just on one date. I have two text boxes; tboStartDate and tboEndDate. So far I'm completely unclear on how to add this functionality. I would love suggestions on how to incorporate this.

    As far as being able to double click on the row like you can on a split form I've only come up with placing an on double click command for each column. like...

    Code:
    Private Sub cboJob_DblClick(Cancel As Integer)
    DoCmd.OpenForm "Try", , , "[JobID] = " & Me!JobID
    End Sub
    Aside form having to enter this for each column, when this is used it will only bring the uppermost record into the form. I assume there is a better way, I'm just unclear what it may be. Please let me know if there is a better way to get my for to behave this way.

    Thank you for looking.



    Attached is my work thus far. Please be kind.
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What you are trying requires form and subform to be bound to same dataset. This usually doesn't work well. This is what the Split form was designed to provide. Select record in 'datasheet' section and it displays in the 'single' section. Can also have unbound controls in form header for input of filter criteria. All the pieces of code you have need to be behind a command button. Review http://www.allenbrowne.com/ser-62.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.

  3. #3
    Stephenson is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Location
    North West
    Posts
    110
    June7,

    Thank you for the link. This looks great. I'm going to see if I can get it to work for me.

    Thanks for the help.

  4. #4
    Stephenson is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Location
    North West
    Posts
    110
    June7,

    This worked great for me. I've been trying to get this to work for way too long. Well, I finally got it thanks to you. I appreciate the help.

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

Similar Threads

  1. Filter subform with two combo boxes
    By dotcanada in forum Forms
    Replies: 4
    Last Post: 07-25-2015, 05:20 PM
  2. Replies: 9
    Last Post: 07-03-2014, 12:00 PM
  3. Filter a Form with Multiple Combo Boxes
    By Njliven in forum Forms
    Replies: 6
    Last Post: 01-03-2013, 01:25 PM
  4. Filter form from multiple combo boxes
    By Bird_FAT in forum Programming
    Replies: 6
    Last Post: 05-19-2010, 09:32 AM
  5. Replies: 1
    Last Post: 03-01-2009, 09:53 AM

Tags for this Thread

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