Results 1 to 5 of 5
  1. #1
    matey56 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2020
    Posts
    188

    Search box question on form


    Hi all,
    I have a continuous form with 3 search boxes in the header. Each box searches a field in the backend table. The user types the criteria and clicks the search button and it works perfectly. The only problem is each time a second/third search is executed it re-queries the entire table. I'd like it to only search the results from the first search. Does that make sense? Is that possible?

    Here is how I set it up?

    Code:
    Private Sub btnSearchBASCode_Click()
    Me.FIND.SetFocus
    Me.FilterOn = False
    Me.Filter = "[BASCode] Like '*" & FIND & "*'"
    Me.FilterOn = True
    Me.Requery
    
    
    End Sub
    
    
    Private Sub btnSearchLocationToller()
    Me.FIND2.SetFocus
    Me.FilterOn = False
    Me.Filter = "[LocationToller] Like '*" & FIND2 & "*'"
    Me.FilterOn = True
    Me.Requery
    
    
    End Sub
    
    
    Private Sub btnSearchConsistencyStatus_Click()
    Me.FIND3.SetFocus
    Me.FilterOn = False
    Me.Filter = "[ConsistencyStatus] Like '*" & FIND3 & "*'"
    Me.FilterOn = True
    Me.Requery
    End Sub

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,570
    You need to combine the filters.
    Test if each has a value and concaternate accordingly.

    Create a sub in the form that does that and call that from your three subs.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    matey56 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2020
    Posts
    188
    Sorry, I'm not sure what you mean by combine the filters. Can you show me?

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,742
    Have a look at this: comboboxes can be clicked in any order.

    Ultimate Dynamic Multiple Cascading Comboboxes, synchronized in any order (accessforums.net)

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,570
    You use AND to combine your filters
    Code:
    Me.Filter = "[BASCode] Like '*" & FIND & "*'" & " AND " & "[LocationToller] Like '*" & FIND2 & "*'"
    Debug.Print Me.Filter or put it into a string variable to see what you actually get, not what you think you have.

    However you have to test each to see if you need to add that filter, as the control for it might be empty.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. combo not putting in table? Also search form question
    By d9pierce1 in forum Programming
    Replies: 5
    Last Post: 09-05-2022, 09:17 AM
  2. Replies: 3
    Last Post: 10-31-2014, 08:08 AM
  3. Another Search Form Question(s)
    By Trojnfn in forum Forms
    Replies: 10
    Last Post: 08-13-2012, 10:54 AM
  4. Search Form and Report Question
    By Trojnfn in forum Access
    Replies: 1
    Last Post: 07-24-2012, 06:26 PM
  5. Search Question
    By SPE_NY in forum Forms
    Replies: 3
    Last Post: 03-02-2011, 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