find a record based on the value you entered in the text box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I display a record based on the value I entered in a text box on form.
I need to display every field associated with that record. Thanks.
 
Funny just told a bloke - Suney how to do this. If you haven't seen it on
this web-site This is what I wrote...

Private Sub MyField_AfterUpdate()
Dim MyO As Object
Set MyO = Me.Recordset.Clone
MyO.FindFirst "[ID] = " & Me.MyField
Me.Bookmark = MyO.Bookmark
End Sub

Hey Suney

The above will go to a record based on a NUMBER that you enter in the field.
You will have to change the "MyField" to whatever your field name is that you
are entering the data you want to use to navigate, and you will have to
change the "[ID]" to what ever FIELD Name you are looking to search in. For
example my code is based on a textbox called "MyField" and within my table of
information I will be searching for all the records which are the same as
"MyField" in the Field Name of "ID".

I hope this is ok for you.

Let me know how it goes

Rich



Hope it's cool for you

Happy Learning Mikey!!!
 
Rich - Thanks for your email. I had similar code before but it didn't work so
I took it out. I used your code below

Dim MyO As Object
Set MyO = Me.Recordset.Clone
MyO.FindFirst "[Customer_Phone] = " & Me.Customer_Phone
Me.Bookmark = MyO.Bookmark

And it gives me error stating No current Record. The value I entered in
customer phone field the record exists for that phone number. Please help.



Rich via AccessMonster.com said:
Funny just told a bloke - Suney how to do this. If you haven't seen it on
this web-site This is what I wrote...

Private Sub MyField_AfterUpdate()
Dim MyO As Object
Set MyO = Me.Recordset.Clone
MyO.FindFirst "[ID] = " & Me.MyField
Me.Bookmark = MyO.Bookmark
End Sub

Hey Suney

The above will go to a record based on a NUMBER that you enter in the field.
You will have to change the "MyField" to whatever your field name is that you
are entering the data you want to use to navigate, and you will have to
change the "[ID]" to what ever FIELD Name you are looking to search in. For
example my code is based on a textbox called "MyField" and within my table of
information I will be searching for all the records which are the same as
"MyField" in the Field Name of "ID".

I hope this is ok for you.

Let me know how it goes

Rich



Hope it's cool for you

Happy Learning Mikey!!!
How do I display a record based on the value I entered in a text box on form.
I need to display every field associated with that record. Thanks.
 
Rich said:
Funny just told a bloke - Suney how to do this. If you haven't seen it on
this web-site This is what I wrote...

Private Sub MyField_AfterUpdate()
Dim MyO As Object
Set MyO = Me.Recordset.Clone
MyO.FindFirst "[ID] = " & Me.MyField
Me.Bookmark = MyO.Bookmark
End Sub


Rich, I didn't see the other thread, but unless there were
some unusual circumstances, I think that code should be more
like:

With Me.RecordsetClone 'not Me.Recordset.Clone
.FindFirst "[ID] = " & Me.MyField 'only for number field
' .FindFirst "[ID] = """ & Me.MyField & """" 'textfield
If Not .NoMatch Then
Me.Bookmark = .Bookmark
Else
MsgBox "Not found"
End If
End With
 
Back
Top