Results 1 to 6 of 6
  1. #1
    Beppe is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Sep 2017
    Posts
    33

    filter records through button

    Dear Access experts,


    I have textboxes where I would like to insert texts and filter the records shown in the form as per this texts. Just beside each textboxs I have put some "filter buttons"; they should filter the records by taking the text from the textboxes.
    For example, there's the textbox "employee" where I put the ID number of the employee, and beside there's the "Employee filter" button.
    What happens is that I apply the macro "applyfilter" to the button, taking as reference the corresponding textbox, but everytime I click on it appears a message box "enter parameter value", where I have to insert the parameter of the filter (for example, 5 for the ID employee).
    I would like that the user could simply click on the filter button and filter the records without this message box..

    Do you know some code for avoiding the macro?

    Please, do you have any idea?? I'm really stuck on this..

    Beppe

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Have you considered using "Filter By Form"
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Beppe is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Sep 2017
    Posts
    33
    No...how does it work?

  4. #4
    Beppe is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Sep 2017
    Posts
    33
    I tried this, but it gives me debug error in the last line

    Code:
    Dim str As String
    
    
    str = "Select * from CODIFICA where"
    str = str & " ID=" & "Forms!Sottomaschera!Identificativo"
    Me!sottomaschera.RecordSource = str

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Quote Originally Posted by Beppe View Post
    No...how does it work?
    See: https://support.office.com/en-gb/art...3-b9b1d1865147 about half way down the page

    and a video at: https://www.youtube.com/watch?v=VoRIcIu059Q
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  6. #6
    Beppe is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Sep 2017
    Posts
    33
    Hello everyone!
    I've solved the problem with the following:

    [code]
    If IsNull(Me.Testo161) Then
    Me.FilterOn = False
    Else
    Me.Filter = "PORTATA Like '" & Me.Testo161.Value & "*" & "'"
    Me.FilterOn = True
    End If
    [/]

    Like this works perfectly! If you want that the button search the exact text you have to delete the '& "*"' from the line.

    Regards
    Beppe

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

Similar Threads

  1. Replies: 9
    Last Post: 02-24-2015, 11:19 AM
  2. Button to filter records when typing something in
    By Doodlebug2000 in forum Forms
    Replies: 1
    Last Post: 12-06-2012, 02:21 PM
  3. Replies: 3
    Last Post: 11-27-2012, 07:20 AM
  4. Replies: 28
    Last Post: 03-08-2012, 06:47 PM
  5. Replies: 3
    Last Post: 07-10-2011, 05:37 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