[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 636
  • Last Modified:

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.


1 Solution
Scott McDaniel (Microsoft Access MVP - EE MVE )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
ghjeffeiiAuthor Commented:
Works beautifully.  Thanks a bunch

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now