GoToRecord help

S

SoggyCashew

Hello, is it possible to have a button on a form and in the on click event
make the form you are going to open, open to the last record? I dont want to
put DoCmd.GoToRecord , , acLast in the forms OnOpen event of the form because
Im using the form to create new records and to show records so one button
might use DoCmd.GoToRecord , , acNewRec and the other acLast. One thing
though the formthat I want to open on the last or new record is a subform on
a form so the forms name is AccidentEntry and its subform "the one I wnat to
have go to acLast or acNewRec" is called AccidentEntrySubform.

is this possible? Thanks!
 
D

Dirk Goldgar

SoggyCashew said:
Hello, is it possible to have a button on a form and in the on click event
make the form you are going to open, open to the last record? I dont want
to
put DoCmd.GoToRecord , , acLast in the forms OnOpen event of the form
because
Im using the form to create new records and to show records so one button
might use DoCmd.GoToRecord , , acNewRec and the other acLast. One thing
though the formthat I want to open on the last or new record is a subform
on
a form so the forms name is AccidentEntry and its subform "the one I wnat
to
have go to acLast or acNewRec" is called AccidentEntrySubform.


Air code:

'----- start of code -----
Private Sub cmdOpenAccidentEntry_Click()

DoCmd.OpenForm "AccidentEntry"

With Forms!AccidentEntry!AccidentEntrySubform.Form.Recordset
If .RecordCount > 0 Then .MoveLast
End With

End Sub
'----- end of code -----
 
D

Dirk Goldgar

SoggyCashew said:
Dirk, How would I move to a new record?


With Forms!AccidentEntry!AccidentEntrySubform.Form
If .AllowAdditions Then
If Not .NewRecord Then
.Recordset.AddNew
End If
End If
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top