PDA

View Full Version : Textbox Search



mattster1010
07-07-2008, 02:39 AM
Good Morning,

I have the following code to input criteria into a textbox called qrysearch that finds records based on a field called username:

Private Sub Command17_Click()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Username] = '" & Me![qrysearch] & "'"
Me.Bookmark = rs.Bookmark

End Sub

The code works, but it seems to find the first record in the detail section of the form and still list every other record, how do perform the same search only displaying records that equal qrysearch.text?

Cheers,

Mattster

OBP
07-07-2008, 02:55 AM
mattster, If you wish to "Pattern match" for a name using the "Like "*" then you should use either a query or an SQL Recordset.
You are using a recordsetClone, which holds all records, not just the ones that you are searching for.
Another alternative is to use a VBA generated Form Filter to do what you want.
See this post
http://vbaexpress.com/forum/showthread.php?t=20275
Post #3.