Access form open with last viewed record?

Posted on 2008-11-14
Medium Priority
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
  • 2
LVL 34

Accepted Solution

Mike Eghtebas earned 2000 total points
ID: 22963315
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 34

Expert Comment

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

Change your code to:

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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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…
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…
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

839 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