Access form open with last viewed record?

Posted on 2008-11-14
Last Modified: 2013-11-28
How can I preserve the last viewed record, so upon reopening it by default it navigates to the same record.  That is last Viewed not Last in the recordset
Question by:Jagstrom
    LVL 33

    Accepted Solution

    tSetting   '<-- make this table
    LastRecorID (number/long)   '<-- for now it has only one field

    If later you want to keep some other user settings then you can add more fields to it.

    In the on current event of your form, have:

    CurrentDB.Execute "Update tSetting Set LastRecorID =" & Me!txtCustID

    Assuming your PK field is called CustID bound to txtCustID text box.

    Note that, tSetting will have only one record (manualy enter a number in it for now).  In the on open event of your form have

    Dim lngID as Long
    lngID = Dolookup("LastRecorID","tSetting")
    Msgbox lngID

    - Open your form. the number you just entered manulay should com up in the message box. Does it?
    - Move to another record (remembering itst CustID value) and close the form.
    - Re-open the form. Does the new CustID come up in the message box?


    LVL 33

    Expert Comment

    by:Mike Eghtebas
    Is you form continous or single form?

    Change your code to:

    Dim lngID as Long
    lngID = Dolookup("LastRecorID","tSetting")
    DoCmd.FindRecord lngID

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
    Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    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

    14 Experts available now in Live!

    Get 1:1 Help Now