chrisjames25
Registered User.
- Local time
- Today, 21:04
- Joined
- Dec 1, 2014
- Messages
- 404
Hi 
Currently have an invoice form with various textboxes on it and a listbox.
THe following code was provided by this forum for me so that when i type something into a textbox it filters the below options in a list box.
	
	
	
		
Take no credit for the code. That was all this forum. My issue is that as i now type in the search textbox the above code at the:
	
	
	
		
sends my main form back to record one no matter what record i am on. No idea why it is doing it. If i remove this line it works perfectly. Or appears to me to work perfectly.
I guess what i am after is an explanation as to what this line of code was intended to do in the context of the above code and am i safe removing it.
 Currently have an invoice form with various textboxes on it and a listbox.
THe following code was provided by this forum for me so that when i type something into a textbox it filters the below options in a list box.
		Code:
	
	
	Private Sub Txt_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 = Txt_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
    Txt_SrchText.Value = vSearchString
'Requery the List Box to show the latest results for the text entered in Text Box SearchFor
    Me.Lst_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.Txt_SrchText) <> 0 And InStr(Len(Txt_SrchText), Txt_SrchText, " ", vbTextCompare) Then
        Exit Sub
    End If
'Set the focus on the first item in the list box
    Me.Lst_SearchResults = Me.Lst_SearchResults.ItemData(0)
    Me.Lst_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.Txt_SearchFor.SetFocus
    If Not IsNull(Len(Me.Txt_SearchFor)) Then
        Me.Txt_SearchFor.SelStart = Len(Me.Txt_SearchFor)
    End If
End SubTake no credit for the code. That was all this forum. My issue is that as i now type in the search textbox the above code at the:
		Code:
	
	
	docmd.requerysends my main form back to record one no matter what record i am on. No idea why it is doing it. If i remove this line it works perfectly. Or appears to me to work perfectly.
I guess what i am after is an explanation as to what this line of code was intended to do in the context of the above code and am i safe removing it.
 
	 
 
		 
 
		 
 
		