Help with Subform and GoToLast command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Daryl Austin
    New Member
    • May 2011
    • 24

    Help with Subform and GoToLast command

    Hi,

    I have a form using tab controls. The 2nd tab control is named "weekly_details " in which I embedded a form called Frm:weeklydetai ls. What I want to happen is when I click on that tab control, the recordset shown is the last record in my table called "weeklydetails" . My logic below doesn't seem to work very well. Any suggestions?

    Code:
    Private Sub Weekly_Details_Click()
        'sets focus to the Subform Form_frm:weeklydetails
        Me.Form_frm: weeklydetails.SetFocus
        'move to the last record of the weekly details database
        DoCmd.RunCommand (acCmdRecordsGoToLast)
    End Sub
    Thanks.

    Daryl
    Last edited by NeoPa; Oct 12 '11, 03:55 PM. Reason: Added mandatory [CODE] tags for you
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    In my view a far simpler solution is to base your subform on a query, and within that query sort the data in reverse order on whatever key field or combination of fields determines the 'last record' you refer to. Access will always then show you the 'last record' when the form is opened.

    -Stewart

    Comment

    • neelsfer
      Contributor
      • Oct 2010
      • 547

      #3
      I use something like this to move to the last record in subform
      Code:
      DoCmd.GoToControl ("subformname")
      DoCmd.GoToRecord , "", acLast

      Comment

      Working...