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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying the last entry in a subform

Status
Not open for further replies.

grgimpy

Programmer
Nov 1, 2006
124
US
I have a form with an "Add Record" button that puts the data into the table fine. There is also a subform on this same form that displays the table along with all the entries. Upon load I have the subform displaying the last data entry by using the code:

Private Sub Form_Load()
DoCmd.GoToRecord , , acLast
End Sub

pretty simple. But after I enter data using my "Add Record" button, the subform does not automatically display the record that was just entered. It is put in the table in the subform, but just doesn't scroll down so you can see it. I feel like this is an easy fix, but I tried using AfterUpdate and some other codes similar to the one above with no luck.

Basically, I want my subform to automatically scroll to the bottom of the table (displaying the last entry) after I update the table using the "Add Record" button.

Thanks
 
try in the code after the data entry me.refresh and subform.refresh if you want a long and simple way you can also base the subform on a query and add in the table a field with the Date/Time and in the default Data put in Now() and in the query mark the date/time field in the totals line last and it will give you only the last record of that table or if you have a autonumber in that table you can use it as well with the max

hope you got it
 
instead of using

Private Sub Form_Load()
DoCmd.GoToRecord , , acLast
End Sub

in the subform code i used

Private Sub Form_Current()
DoCmd.GoToRecord , , acLast
End Sub

and this works great. except for when i open my main form, which has a few tabs containing other forms, i get a "send error report" type error where my database must shut down. it continues giving me this error until i take the Form_Current() code out. does anyone know why this would happen? the forms by themselves load fine, but when i try and open them all at the same time an error shuts down access.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top