PDA

View Full Version : Using an Unbound Textbox To Search



mattster1010
07-07-2008, 02:20 AM
Good Morning All,

I have created a textbox on a form that I want to be able to type in a users name to search the detail of a form. The unbound textbox to search in is called 'qrysearch' and I want a textbox called 'Username' to be the lookup source. I have written the code below to be called on an onclick event with a command button:

Private Sub Command17_Click()
DoCmd.ShowAllRecords
Set rstClone = Me.RecordsetClone
rstClone.FindFirst "[Username] = " & Me.qrysearch & ""
Me.Bookmark = rstClone.Bookmark
Set rstClone = Nothing

End Sub

Everytime I try searching for Smith (Example) I get the following error message:

Run Time error 3070:

The microsoft jet database engine does not recognize 'smith' as a valid field name or expression.

Can anyone tell me what Im doing wrong here?

Cheers,

Mattster

OBP
07-07-2008, 02:52 AM
mattster, why use an unbound box to type in a user naem, why not use a Combo box.
If you wish to "Pattern match" for a name using the "Like "*" then you should use either a query or an SQL Recordset.