Hi, i am using the code created by "John Big Booty" to search a list box. I would like to add some option frames which will further filter the list box.
I am using this code
I have mimiced John's query and form coding but cannot seem to get the same result.
This is a copy of his DB.
I am naming the field with the same name as the crietria entered into the query. But the reult is either nothing, or all of the records in the listbox disapperaring.
Thanks a lot, just wondered if there was something missing
I am using this code
Code:
'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 QRY_SearchAll
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
I have mimiced John's query and form coding but cannot seem to get the same result.
This is a copy of his DB.
I am naming the field with the same name as the crietria entered into the query. But the reult is either nothing, or all of the records in the listbox disapperaring.
Thanks a lot, just wondered if there was something missing