Results 1 to 7 of 7
  1. #1
    Moonman is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    8

    Cool Multiple Form Filter Criteria vba code

    I have developed a form that has a several work tasks assigned to individual engineers. I have programmed a combo using the Filter command and a command button to allow the user to select the engineer and then click the button to apply the form filter in respect to the combobox engineer. This works great, but now I have added two radio buttons, to allow the user the option of filtering work tasks that are within 12 weeks of execution and thos tasks that are beyond the 12 week period, which each version of code working perfectly independently, but I cannot figure out how to tie all three sets of code together, it seems to be loading applying the last filter in the code only. Any assistance would be greatly appreciated - - I have been working on this for 8 hours straight and have at my wits end!!!

    Thank you,

    Moonman

    Private Sub Command166_Click()
    Me.Filter = "[tblMain.Engineer] = '" & Me.Combo162 & "'"

    BeginDate = Date
    EndDate = DateAdd("d", "84", Date)
    EndDate2 = DateAdd("d", "84", EndDate)

    If (Me.Option156 = True) Then
    Me.Filter = "[Start] BETWEEN #" & BeginDate & "# AND #" & EndDate & "#"
    Else
    MsgBox "You currently have no assigned work activities for T-0 thru T-12"
    End If

    If (Me.Option158 = True) Then
    Me.Filter = "[Start] BETWEEN #" & EndDate & "# AND #" & EndDate2 & "#"


    ElseMsgBox "You currently have no assigned work activities at T-13 and beyond"
    End If

    Me.FilterOn = True
    End Sub

  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,518
    Sure, as you keep overwriting the filter. You'd have to have " AND " between each, like

    Me.Filter = Me.Filter & " AND [Start] BETWEEN #" & BeginDate & "# AND #" & EndDate & "#"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    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.

  4. #4
    akhmadahdiyat is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Oct 2013
    Posts
    21
    Code:
    Private Sub Command166_Click()
    Me.Filter = "[tblMain.Engineer] = '" & Me.Combo162 & "'"
    
    BeginDate = Date
    EndDate = DateAdd("d", "84", Date)
    EndDate2 = DateAdd("d", "84", EndDate)
    
    If (Me.Option156 = True) Then
    Me.Filter = Me.Filter  & " AND [Start] BETWEEN #" & BeginDate & "# AND #" & EndDate & "#"
    Else
    MsgBox "You currently have no assigned work activities for T-0 thru T-12"
    End If
    
    If (Me.Option158 = True) Then
    Me.Filter = Me.Filter  & " AND [Start] BETWEEN #" & EndDate & "# AND #" & EndDate2 & "#"
    ElseMsgBox "You currently have no assigned work activities at T-13 and beyond"
    End If
    
    Me.FilterOn = True
    End Sub

  5. #5
    Moonman is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    8

    Cool

    Quote Originally Posted by pbaldy View Post
    Sure, as you keep overwriting the filter. You'd have to have " AND " between each, like

    Me.Filter = Me.Filter & " AND [Start] BETWEEN #" & BeginDate & "# AND #" & EndDate & "#"
    Thank you so much, it works perfectly - - so hard for some, so easy for others. Thanks again!!!!

    Moonman

  6. #6
    Moonman is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    8
    Thank you for the helpful link!!!

    Moonman

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 10-16-2013, 03:44 PM
  2. VBA code multiple export to xml with filter
    By Bertrand82 in forum Programming
    Replies: 9
    Last Post: 01-15-2013, 03:55 AM
  3. Replies: 7
    Last Post: 10-13-2012, 10:53 AM
  4. Replies: 1
    Last Post: 12-04-2011, 06:33 PM
  5. Replies: 1
    Last Post: 02-03-2010, 08:17 AM

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