using textbox value to find record in recordset

G

Guest

How to retrive a record in my recordset by using a value that i type in the
textbox ? Consider i have recordset name : rst. and a field name : LastName.
Then i use textbox name : txtLastName to find the specific record in LastName
field(table).

it's working when i use the txtID ( dim as long ) but not with txtLastName (
dim as string ). What realy is the datatype for txtLastName ?
 
G

Guest

It’s the data type of the LastName field that's important here. This will be
Text so, unlike with a number, the value will have to be wrapped in quotes
characters. Literal quotes characters in a string expression are indicated
by using doubled quotes characters so if for instance you want to go to the
first record in a form which matches the name the code would be:

Dim rst As Object

Set rst = Me.Recordset.Clone

rst.FindFirst "LastName = """ & txtLastName & """"
Me.Bookmark = rst.Bookmark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top