Return to current record after removing filter

I've seen this type of question mentioned before, but I was unable to find a solution.  I'm looking for a way to simply return to the current record on a form after removing its filter.  I use the DoCmd.OpenForm method to open a form w/ filter applied & once I have the filter applied I can't remove it w/out returning to the first record in the form's record source.  I've tried declaring an integer variable & assigning its value the Me.CurrentRecord property & then using the variable in the DoCmd.GoToRecord method, but was unsuccessful.  Any help would be greatly appreciated.

Thanks,

Gary
ghjeffeiiAsked:
Who is Participating?
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Connect With a Mentor Infotrakker SoftwareCommented:
You'd need to store the value of the ID value of that record (if you're using autonumbers, then store the Autonumber value), then go back using the recordsetclone.

dim lID As Long
Dim rst As DAO.recordset

lID = Me.YourIdValue
<remove the filter>
set rst = Me.Recordsetclone
rst.findFirst "YourIDField=" & lID
If Not rst.NoMatch Then
  Me.Bookmark = rst.Bookmark
End If
0
 
ghjeffeiiAuthor Commented:
Works beautifully.  Thanks a bunch
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.