Results 1 to 8 of 8
  1. #1
    Z1nkstar's Avatar
    Z1nkstar is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Location
    TX, USA
    Posts
    145

    Access Form Filters?????


    I have an access form that has a drop down menu of numbers 1-5 and i need to be able to filter the data on the form by that number can anyone help me find a way to make the filter or can give me a code that will filter the data by what number has been chosen?
    And if there is another way that I can filter I am open you can send it to my email or to me here
    pm if you want my email.
    Click image for larger version. 

Name:	hyhyhyhyh.jpg 
Views:	12 
Size:	132.9 KB 
ID:	15748

    Click image for larger version. 

Name:	wwwwwwwww.JPG 
Views:	12 
Size:	100.3 KB 
ID:	15747

  2. #2
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Code:
    Private Sub BuildLeader_Afterupdate()
    
    Dim strFilter As String
    Dim blnFilter As Boolean
    
    blnFilter = False
    
    strFilter = " 1=1 "
    If Me.BuildLeader <> "" Then
    strFilter = strFilter + " and BuildLeader = '" & BuildLeader & "'"
    blnFilter = True
    If blnFilter Then
    Me.Filter = strFilter
    Else
    Me.Filter = "1=2"
    End If
    
    Me.FilterOn = True
    
    End Sub
    Put this in the afterupdate event of the dropdown box.
    Asuming the field in your table is named BuildLeader as well. If its not, then edit it.

  3. #3
    Z1nkstar's Avatar
    Z1nkstar is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Location
    TX, USA
    Posts
    145
    Okay I added it like so and got this error.
    Click image for larger version. 

Name:	5454545454545454.JPG 
Views:	8 
Size:	79.3 KB 
ID:	15749

    Quote Originally Posted by JeroenMioch View Post
    Code:
    Private Sub BuildLeader_Afterupdate()
    
    Dim strFilter As String
    Dim blnFilter As Boolean
    
    blnFilter = False
    
    strFilter = " 1=1 "
    If Me.BuildLeader <> "" Then
    strFilter = strFilter + " and BuildLeader = '" & BuildLeader & "'"
    blnFilter = True
    If blnFilter Then
    Me.Filter = strFilter
    Else
    Me.Filter = "1=2"
    End If
    
    Me.FilterOn = True
    
    End Sub
    Put this in the afterupdate event of the dropdown box.
    Asuming the field in your table is named BuildLeader as well. If its not, then edit it.

  4. #4
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Sorry, my bad.

    Code:
    Private Sub BuildLeader_Afterupdate()
    
    Dim strFilter As String
    Dim blnFilter As Boolean
    
    blnFilter = False
    
    strFilter = " 1=1 "
    If Me.BuildLeader <> "" Then
    strFilter = strFilter + " and BuildLeader = '" & BuildLeader & "'"
    blnFilter = True
    end if
    If blnFilter Then
    Me.Filter = strFilter
    Else
    Me.Filter = "1=2"
    End If
    
    Me.FilterOn = True
    
    End Sub

  5. #5
    Z1nkstar's Avatar
    Z1nkstar is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Location
    TX, USA
    Posts
    145
    It Works but when i try to filter the data this is what im getting???
    Its just changing the value of the build leader for the first build?

    Click image for larger version. 

Name:	222222222222222222222222222222.JPG 
Views:	6 
Size:	48.9 KB 
ID:	15750
    Click image for larger version. 

Name:	33333333333333.JPG 
Views:	7 
Size:	46.7 KB 
ID:	15751
    Quote Originally Posted by JeroenMioch View Post
    Sorry, my bad.

    Code:
    Private Sub BuildLeader_Afterupdate()
    
    Dim strFilter As String
    Dim blnFilter As Boolean
    
    blnFilter = False
    
    strFilter = " 1=1 "
    If Me.BuildLeader <> "" Then
    strFilter = strFilter + " and BuildLeader = '" & BuildLeader & "'"
    blnFilter = True
    end if
    If blnFilter Then
    Me.Filter = strFilter
    Else
    Me.Filter = "1=2"
    End If
    
    Me.FilterOn = True
    
    End Sub

  6. #6
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Im not behind my pc anymore so i cant look closely to the sceenshots but in my code the first buildleader im mentioning should be the name of the dropdownbox.
    The second buildleader in the code is the field in your table that you wish the data to be filtered.
    The third time should be the name of the dropdownbox again.

    The filter is normally used to combine search criteria. But it should work fine with just one criteria.

    Let me know if it works

  7. #7
    Z1nkstar's Avatar
    Z1nkstar is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Location
    TX, USA
    Posts
    145
    Thanks works Perfectly

  8. #8
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Your welcome mate.
    If you havent done it allready could you mark the thread as "solved" ?
    You can find it under thread tools.

    Kind regards,

    Jeroen

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

Similar Threads

  1. Table to Form Filters
    By icloudy in forum Forms
    Replies: 1
    Last Post: 07-31-2013, 04:45 PM
  2. Filters not running in Access 2010
    By Andrus_n in forum Queries
    Replies: 0
    Last Post: 01-26-2012, 07:00 AM
  3. Replies: 5
    Last Post: 05-26-2011, 04:35 PM
  4. Form Filters Help
    By JeffG3209 in forum Forms
    Replies: 1
    Last Post: 05-22-2011, 10:31 PM
  5. Creating Filters on a Form
    By Nixx1401 in forum Access
    Replies: 4
    Last Post: 02-27-2010, 05:32 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