Open Form Move to last record (1 Viewer)

MarkA70

Registered User.
Local time
Today, 10:46
Joined
Jan 30, 2016
Messages
43
SOLVED: Open Form Move to last record

I am trying to open a form and move to the last record. I am using this code:


Private Sub Form_Load()
If Me.RecordsetClone.RecordCount > 0 Then
Me.RecordsetClone.MoveLast
End If
End Sub


It does not move me to last record, how might it be modified?
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:46
Joined
May 7, 2009
Messages
19,230
Code:
Private Sub Form_Load()
dim rs As Dao.Recordset
set rs = Me.RecordSetClone
with rs
If Not (.BOF and .EOF) Then
.MoveLast
Me.BookMark = rs.Bookmark
End If
.Close
End With
End Sub
 
Last edited by a moderator:

isladogs

MVP / VIP
Local time
Today, 16:46
Joined
Jan 14, 2017
Messages
18,211
another method is just to sort the form records in revere order so the first record is the latest entered.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:46
Joined
Feb 19, 2002
Messages
43,233
"Last" has meaning only in flat files. If you always want to see the most recent entry when you open a form, sort the form's RecordSource query, descending on the Autonumber.

PS, I never bind my forms to tables or to queries without criteria but as long as you never need to upsize this application to SQL Server, you'll probably be OK.
 

Users who are viewing this thread

Top Bottom