Jump to specific record on opening (1 Viewer)

RichStone

Registered User.
Local time
Today, 13:43
Joined
Oct 18, 2013
Messages
21
My database records the reference of the last record opened in a field on the main menu. When the records are selected from the main menu again I would like the record with that reference to open first. I tried setting a filter but I then can't move to other records. What is the best method to do this?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:43
Joined
May 7, 2009
Messages
19,233
use the Load event of your form to go to that record:

Private Sub Form_Load()
Dim rs As Dao.RecordSet
If Trim(Forms!MainMenuForm!yourReference & "") <> "" Then
set rs = Me.RecordsetClone
with rs
.FindFirst "[PKField] = " & Forms!MainMenuForm!yourReference
If Not .NoMatch Then Me.BookMark = rs.BookMark
.Close
end with
end if
set rs=nothing
End Sub
 

RichStone

Registered User.
Local time
Today, 13:43
Joined
Oct 18, 2013
Messages
21
Thanks for the reply.

I have copied the code into the Load event and changed the references to those in my database but now I'm getting a compile error that says User defined type not defined and the code is paused on the Dim instruction. Any ideas?
 

bentheimmigrant

Lost & confused
Local time
Today, 13:43
Joined
Aug 21, 2015
Messages
60
I copied it in directly, and the "Dao" did not auto-capitalise. Try re-typing it, as it should be "DAO".
 

RichStone

Registered User.
Local time
Today, 13:43
Joined
Oct 18, 2013
Messages
21
Issue solved. I used some completely different code I managed to find in another thread.

Thanks for everyone's help anyway!
 

ddcessex

Registered User.
Local time
Today, 05:43
Joined
Jan 14, 2016
Messages
23
Issue solved. I used some completely different code I managed to find in another thread.

Well, we're all in suspense!

We're all interested in successful solutions so what was yours?
 

Users who are viewing this thread

Top Bottom