BaldyWeb

Remain on a Selected Record After Requerying Form

Sometimes you need to requery a form to refresh the data it contains, but you want to remain on the record you're currently on rather than having focus go to the first record, which is the normal behavior after a requery.  One method involves using a bookmark.  The guts of the code:

Dim rs As Object
Dim lngBookmark As Long

'set a variable to the current record
lngBookmark = Me.EmpID
'requery the form
Me.Requery

'bring us back to the original record
Set rs = Me.RecordsetClone
rs.FindFirst "EmpID = " & lngBookmark
Me.Bookmark = rs.Bookmark

Set rs = Nothing

And a sample to show the process in action:

Requery with bookmark sample db

Home