Results 1 to 6 of 6
  1. #1
    dgmdvm is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2014
    Posts
    84

    Cycling through records problem in a subform.

    I have a form named Services_subform and a subform of that named Serviceshistory_subform. Services_subform is a single form and ServicesHistory_subform is a datasheet form. There is a one-to many relationship between the tables that are the record sources for these subforms- tblServiceIstance for the Services_subform and tblServiceHistory for ServicesHistory_subform. The forms work correctly except for cycling through the records.



    I created some arrow buttons on the Services_subform so that I could move between records on the Services_subform. When I push the button, it cycles through all the records on the ServicesHistory_subform first and then moves to the next record of the Services_subform. I don't want that behavior but not sure how to fix it. If I enable the navigation buttons on the subform it works correctly but I intend to disable those buttons.

    Here is a sample of the the code for moving to the next record. I also have a similar script for moving to the previous record.

    Code:
    Private Sub CmdNextServiceInstance_Click()On Error GoTo Err_CmdNextServiceInstance_Click
    
    
     With Me.RecordsetClone
     
      If Not .EOF Then
          .MoveNext
           Me.Bookmark = .Bookmark
      Else
         Exit Sub
      End If
    End With
        
    Exit_Err_CmdNextServiceInstance_Click:
    Exit Sub
    
    
    Err_CmdNextServiceInstance_Click:
    Msgbox Err.Description
    Resume Exit_Err_CmdNextServiceInstance_Click
    End Sub
    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    If this code is behind Services_subform, why would it cycle through ServicesHistory_subform? This needs to be resolved.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    dgmdvm is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2014
    Posts
    84
    Quote Originally Posted by June7 View Post
    If this code is behind Services_subform, why would it cycle through ServicesHistory_subform? This needs to be resolved.
    The code is on the services_subform; it doesn't make sense why. I'll make a stripped out copy tomorrow. I suspect the solution is easy, just don't know where to start.

  4. #4
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,404
    Couldn't get that code to work, kept getting "No Current Record" at the bookmark line.
    Here's what I've used to replace the navigation buttons with good luck:

    Code:
    Private Sub cmdFirst_Click()
        On Error Resume Next
        DoCmd.GoToRecord , , acFirst
    End Sub
    Private Sub cmdNext_Click()
        On Error Resume Next
        DoCmd.GoToRecord , , acNext
    End Sub
    Private Sub cmdPrevious_Click()
        On Error Resume Next
        DoCmd.GoToRecord , , acPrevious
    End Sub
    Private Sub cmdLast_Click()
        On Error Resume Next
        DoCmd.GoToRecord , , acLast
    End Sub

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  6. #6
    dgmdvm is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2014
    Posts
    84
    I found my error! The problem was not with either subform referenced above or their code. I have another subform that is part of a tabbed control. This 3rd subform serves as a summary sheet for the data on the forms listed above. The tabbed control has a query in it to allow late binding of the data when the tab is clicked. Instead of requerying the summary subform it was requerying the services_subform. My bad. Your answer gave me some direction anyway so I got it figured out.

    Thanks for the help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 01-18-2017, 12:41 PM
  2. Replies: 1
    Last Post: 10-21-2012, 04:57 PM
  3. Replies: 3
    Last Post: 08-22-2012, 12:49 PM
  4. Cycling through subform Records
    By paddon in forum Programming
    Replies: 3
    Last Post: 05-10-2011, 10:20 AM
  5. Printing reports and cycling through records
    By dabman in forum Programming
    Replies: 4
    Last Post: 12-15-2009, 11:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums