Easy Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a simple form that overlays a table and I use it for simple data
entry. How do I get it to go to the last record when I open the form? Or
better yet, go to a blank field so I can enter a new record?

Thanks so much,
Sean
 
Sean

The GoTo command has a bunch of options, but here are the 2 you asked for.

Private Sub Form_Load()
'Go to last record
DoCmd.GoToRecord , Record:=acLast

'Go to new record
DoCmd.GoToRecord , Record:=acNewRec

End Sub
 
If want the new record without bothering to load all the old ones, just set
the
Data Entry
property of the form to Yes.

If you do want it to load the old records, but go to the new one, set the
form's On Load property to:
[Event Procedure]
Click the Build button (...) beside the property.
Access opens the code window.
Enter the 3 lines below between the "Private Sub..." and "End Sub":

Private Sub Form_Load()
If Not Me.NewRecord Then
RunCommand acCmdRecordsGotoNew
End If
End Sub

If you want the form to open at the record you were working with last time
you closed the form, there's a bit more to it. See:
Return to the same record next time form is opened
at:
http://allenbrowne.com/ser-18.html
 
Back
Top