Solved open form with last record

kobiashi

Registered User.
Local time
Today, 15:12
Joined
May 11, 2018
Messages
258
Hi all,

Im trying to open a form to the last record via a button but cant seem to find the correct command so i currently have

Code:
sub CmdOpenForm_Click()
       DoCmd.OpenForm FormName:="FrmEventNewTrackPart", DataMode:= acLastRecord
End Sub


But that doesnt work

can i run a DoCmd.OpenForm followed by DoCmd.GoToRecord from the button?
 
Hi all,

Im trying to open a form to the last record via a button but cant seem to find the correct command so i currently have

Code:
sub CmdOpenForm_Click()
       DoCmd.OpenForm FormName:="FrmEventNewTrackPart", DataMode:= acLastRecord
End Sub


But that doesnt work

can i run a DoCmd.OpenForm followed by DoCmd.GoToRecord from the button?
Try:
DoCmd.GoToRecord , , acLast
 
Last edited:
Try:
DoCmd.GoToRecord , , acLast
will that work from the button click?
also what would that openm a specific form?
 
will that work from the button click?
also what would that openm a specific form?
Could be applied using "Button" after open a form
DoCmd.OpenForm "FrmEventNewTrackPart"

then set on "Event Procedure" during "Form Load" that if last record is required always to viewed.
DoCmd.GoToRecord , , acLast
 
Last edited:
As you have been advised by others, "Last" is a questionable term in a relational database. If "Last Record" means the record changed most recently then then you must have a way to remember either WHEN something was changed (like a date/time field for "last updated on") or IN WHAT ORDER something was changed (like some sort of autonumbering scheme that updates record numbers of updated records.
 
Code:
Sub CmdOpenForm_Click()
       DoCmd.OpenForm FormName:="FrmEventNewTrackPart"
      
       'arnelgp
       With Forms!FrmEventNewTrackPart.Recordset
            If Not (.BOF And .EOF) Then
                .MoveLast
            End If
        End With

End Sub
 
Or by using cmdOpenForm button then insert;

DoCmd.OpenForm "FrmEventNewTrackPart": DoCmd.GoToRecord , , acLast

MsgBox "FormLoaded goto LastRecord... " _
& vbCrLf & "ID: " & Forms![FrmEventNewTrackPart]![ID] & "= " _
& Forms![FrmEventNewTrackPart]![ranyfield], vbInformation
 
Last edited:
thanks everyone for your replies, ive resolved this issue now by use of Docmd.GoToRecord ,, acLast. this did what i wanted
 
Last edited:

Users who are viewing this thread

Back
Top Bottom