Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jun 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Next Record on a Subform (2003)

    I saw similar posts on this already; unfortunately, I am not savvy enough to adapt that information to my situation.

    I have a form [frmMain] that has a subform object [sfrmResource] and a combo box [cboChoice]. The source object for [sfrmResource] is set based on the user's choice in the [cboChoice] and the form that becomes the subform's source object is set to Data Entry. I would like to have a command button [cmdNext] on [frmMain] that the user can click to move to the next record in [sfrmResource].

    What would the code for [cmdNext] have to be?

    Thanks!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Next Record on a Subform (2003)

    Access provides navigation buttons on a form, so the user could easily click the 'next record' button in the navigation buttons in the subform itself.

    If you still want to use a command button on the main form, the On Click code would look like this:

    Private Sub cmdNext_Click()
    Me.sfrmResource.SetFocus
    On Error Resume Next
    RunCommand acCmdRecordsGoToNext
    End Sub

    The line On Error Resume Next suppresses the error message that would be displayed if the subform is on a blank new record.

  3. #3
    New Lounger
    Join Date
    Jun 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Next Record on a Subform (2003)

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •