Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Go to last record when form is opened

Status
Not open for further replies.

vistor

Technical User
Dec 22, 2000
164
0
0
US
When the form is opened I want the new blank record to be up OR if this is not possible then the last record.
 
Are you saying you want to open the form to a new record? if so, use this:

DoCmd.OpenForm "YourFormName", acNormal, , , acFormAdd

If you simply want to go to the last record, then On Open of your form use this:

DoCmd.GoToRecord , , acLast Jim Lunde
compugeeks@hotmail.com
Custom Application Development
 
Another way is to set the form's Data Entry property to True. Access will then open the form ready to add a record. The user can still use it for browsing and editing existing records (if Allow Edits is Yes) by removing filtering with the menu or toolbar button, and can return to Data Entry mode by choosing Records>Data Entry from the menu. Rick Sprague
 
I want to do this same thing (Open a form and go to the last record) except mine is in a sub form. When I put the DoCmd.GoToRecord , , acLast in my subform and open it... it does exactly what I want. When I open my main form though, I get an error saying that the subform isn't open yet.

Where do I need to place this code so that my subform goes automatically to the last record?

thanks a bunch!
 
Do you have a Macro that opens your main form? If so you need to add another action.

Open the macro in design view. Add A GoTo Rrecord action below the OpenForm action.

The action arguments will be as follows:
Object Type: Form
Object Name: the name of your main form
Record: chose last or new if you want it to open to a new blank record.

Hope this helps.
 
If what you are doing is designed to display the last (and presumably the LATEST record in the subform) why not change the sort order for the subform to Descending?

This will automatically bring the latest records to the top of the form whenever the form/subform is opened. As new records are added to the subform, they will also be automatically sorted to the top the next time the form is opened.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top