Jump to specific record on opening

RichStone

Registered User.
Local time
Today, 00:36
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?
 
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
 
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?
 
I copied it in directly, and the "Dao" did not auto-capitalise. Try re-typing it, as it should be "DAO".
 
Issue solved. I used some completely different code I managed to find in another thread.

Thanks for everyone's help anyway!
 

Users who are viewing this thread

Back
Top Bottom