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 record of a query in a subform upon open

Status
Not open for further replies.

grgimpy

Programmer
Nov 1, 2006
124
US
I have made a form where the data that is entered is recorded and displayed in a subform based off of a query. The query displays the records by Date and Time in ascending order. When I open the form, the subform displays the first record in the query. I would like the subform to automatically display the last record (most recent) instead. I can't have the query display the date/time in descending order for other reasons.

Basically, I need a code that will automatically scroll my query to the bottom in the subform when I open the main form.

Thanks
 
In the Load event procedure of the subform:
Me.Recordset.MoveLast

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
You can use the recordset clone and a bookmark. Something like (on the subform):

[tt]Dim rs as DAO.Recordset
Set rs = Me.RecordsetClone
rs.Movelast
Me.Bookmark=rs.Bookmark[/tt]
 
Thanks for the responses. I ended up doing something a little different that seems to work fine so far.

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

I wasn't writing the code in the subform, which was most of the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top