Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Spaces to Dynamic Search

Status
Not open for further replies.

marina9

Programmer
Mar 5, 2002
32
US
I have a mini search tool where I have the users enter a client's name in a textbox and with each keystroke the record listing becomes more specified. The problem is when ever a user needs to enter a space in the search textbox the cursor just moves to the end of the word and hangs there. I entered my code in the textbox's Change event procedure:

Dim strClient As String

txtSearchClient.SetFocus
strClient = txtSearchClient.Text

If strClient <> &quot;&quot; Then
Me.RecordSource = &quot;SELECT * FROM qryClientListing WHERE [ClientName] LIKE '&quot; & strClient & &quot;*'&quot;
If Me.RecordsetClone.BOF = True And Me.RecordsetClone.EOF = True Then
MsgBox &quot;No Records Found&quot;
Me.RecordSource = &quot;SELECT * FROM qryClientListing&quot;
txtSearchClient.SetFocus
txtSearchClient.Text = &quot;&quot;
End If
Else
Me.RecordSource = &quot;SELECT * FROM qryClientListing&quot;
End If

txtSearchClient.SetFocus
txtSearchClient.SelStart = txtSearchClient.SelLength + 1

It works great for alphanumeric characters, but gets hosed with the space. Any helped would be much appreciated! Thanks!!!
 
Are you saying that the change event does not fire off when a space is pressed?
 
Thanks for replying! I believe the change event is still firing when I press the spacebar, but it continues to go to the last character of the word. It is almost as if it does not recognize &quot;space&quot; as a type of character. For example, when a user enters the word &quot;delaware&quot; and wants to narrow between &quot;delaware c&quot; and &quot;delaware p&quot;, the system will not allow the user to type &quot;delaware &quot;. The cursor will remain directly after the &quot;e&quot; regardless of how many times you press the spacebar. But the user can enter any other alphanumeric character with no problem.
 
Strange......Works for me in Access 2002. Have you checked for improper input mask on the text box that might be restricting input?
 
I'm having this problem, too. I added the space key bit to the code below.


Code:
Select Case KeyCode
Case Is = 32  ' Ignore space key

This allows me to type the space key. You can type letters after the space key which will choose between C or E or whatever, but it won't filter out entries that don't have a space in them, which is also what I need.
 
Great! Thanks for everyone's help on this. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top