Move Recordpointer in Subform

  • Thread starter Thread starter Terry@Large
  • Start date Start date
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
 
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)
 
Back
Top