Results 1 to 2 of 2
  1. #1
    cpullen91 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2016
    Posts
    9

    Search in a list box

    I have created a search text box that coincides with a list box. this works well but after every character i type i get a pop up box asking for "Enter Parameter Value for 'qrymachine.SuffixName'"



    this is the code im using

    Code:
    Private Sub SearchFor_Change()
    'Create a string (text) variable
        Dim vSearchString As String
    
    
    'Populate the string variable with the text entered in the Text Box SearchFor
        vSearchString = SearchFor.Text
    
    
    'Pass the value contained in the string variable to the hidden text box SrchText,
    'that is used as the sear4ch criteria for the Query QRYsearch
        SrchText.Value = vSearchString
    
    
    'Requery the List Box to show the latest results for the text entered in Text Box SearchFor
        Me.SearchResults.Requery
    
    
    
    
    'Tests for a trailing space and exits the sub routine at this point
    'so as to preserve the trailing space, which would be lost if focus was shifted from Text Box SearchFor
        If Len(Me.SrchText) <> 0 And InStr(Len(SrchText), SrchText, " ", vbTextCompare) Then
            'Set the focus on the first item in the list box
                Me.SearchResults = Me.SearchResults.ItemData(1)
                Me.SearchResults.SetFocus
            'Requery the form to refresh the content of any unbound text box that might be feeding off the record source of  the List Box
                DoCmd.Requery
            'Returns the cursor to the the end of the text in Text Box SearchFor,
            'and restores trailing space lost when focus is shifted to the list box
                Me.SearchFor = vSearchString
                Me.SearchFor.SetFocus
                Me.SearchFor.SelStart = Me.SearchFor.SelLength
                
            Exit Sub
        End If
    
    
    'Set the focus on the first item in the list box
        Me.SearchResults = Me.SearchResults.ItemData(1)
        Me.SearchResults.SetFocus
    
    
    'Requery the form to refresh the content of any unbound text box that might be feeding off the record source of  the List Box
        DoCmd.Requery
    
    
    'Returns the cursor to the the end of the text in Text Box SearchFor
        Me.SearchFor.SetFocus
    
    
        If Not IsNull(Len(Me.SearchFor)) Then
            Me.SearchFor.SelStart = Len(Me.SearchFor)
        End If
    End Sub
    Do you have any idea why it is asking for a parameter?

    I have copied this from another form in the same database which then does not ask for any parameter value. (i have obviously changed the name of the list boxes that it looks for)

    Many Thanks in advance

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You have marked this thread as Solved. Is it? If so, do you care to share your solution with others or should I just delete this thread?

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

Similar Threads

  1. A-Z Search List Help
    By pattrickcolin in forum Access
    Replies: 3
    Last Post: 08-29-2015, 03:14 PM
  2. Replies: 3
    Last Post: 09-02-2013, 04:33 PM
  3. Search List Box with Text Box
    By dalton in forum Access
    Replies: 6
    Last Post: 01-30-2013, 09:58 AM
  4. Search From List and Key Search
    By netchie in forum Forms
    Replies: 14
    Last Post: 02-23-2012, 01:37 PM
  5. Search form with list boxes
    By scottay in forum Programming
    Replies: 15
    Last Post: 07-27-2010, 09:28 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