Return to current record after removing filter

Posted on 2009-04-28
Last Modified: 2013-11-28
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.


Question by:ghjeffeii
    LVL 84

    Accepted Solution

    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

    Author Closing Comment

    Works beautifully.  Thanks a bunch

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    This article is a continuation or rather an extension from Cascading Combos ( and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now