Access form open with last viewed record?

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
JagstromAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike EghtebasDatabase and Application DeveloperCommented:
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

Test:
- 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?

brb

Mike
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike EghtebasDatabase and Application DeveloperCommented:
Is you form continous or single form?

Change your code to:

Dim lngID as Long
lngID = Dolookup("LastRecorID","tSetting")
txtCuset.SetFocus
DoCmd.FindRecord lngID
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

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.