Open Form Move to last record

MarkA70

Registered User.
Local time
Yesterday, 20:20
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:
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:
another method is just to sort the form records in revere order so the first record is the latest entered.
 
"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

Back
Top Bottom