Move Recordpointer in Subform

T

Terry@Large

How can I move the recordpointer in a subform to the
record I select in an unbound text box? I have a form
with an unbound text box that I enter let's say a name.
When I hit return I want the recordpointer of a subform
with names to go to that name and place the name in the
first row of the subform with subsequent names in the
following rows. Is it possible to do a "find" within a
grid subform?

Thanks for the help,
Terry
 
J

John Viescas

Sure. Try something like this:

Dim rst As DAO.Recordset
' Get a copy of the form's recordset
Set rst = Me.RecordsetClone
' Try to find the name specified
rst.FindFirst "[PersonName] = '" & Me.txtNameSearch & "'"
' If found,
If Not rst.NoMatch Then
' Move to that record by setting the bookmark
Me.Bookmark = rst.Bookmark
' .. and move that row to the top
Me.SelTop = Me.CurrentRecord
End If
Set rst = Nothing


--
John Viescas, author
"Microsoft Office Access 2003 Inside Out" (coming soon)
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
 

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