Results 1 to 4 of 4
  1. #1
    ser01 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2010
    Posts
    64

    Moving to next/previous record in a form.

    I have a form that has a text box in the header. It is bound to a [Customer_Name] field in a customer list table. I would like to have a button(s) that would allow me to move to the next/previous customer.
    I have tried a few things:
    DoCmd.RunCommand acCmdRecordsGoToNext
    DoCmd.GoToRecord acDataTable, "tblCustomerList", acNext


    Also tried to use the control wizard. That generated a macro for the move next, but it did not work. What gives?
    Any suggestions would be appreciated.
    Last edited by ser01; 08-06-2012 at 06:08 AM.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Try the MoveNext and MovePrevious methods. Example:
    DoCmd.GoToRecord acForm, "SampleInfo", acPrevious

    Review http://bytes.com/topic/access/answer...ns-access-form

    Here is another way http://www.java2s.com/Code/VBA-Excel...NextButton.htm
    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
    ser01 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2010
    Posts
    64
    Thank you very much for your reply.
    I tried the method described here last night, and it did not work. I got an error about the table not being opened. However, I tried again just now and it works fine. Very strange.
    Again, thanks for your help.
    Last edited by ser01; 08-07-2012 at 09:06 PM.

  4. #4
    Missinglinq's Avatar
    Missinglinq is online now VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Code:
    Private Sub cmdNext_Click()
      If CurrentRecord = RecordsetClone.RecordCount Then
        MsgBox "You are on the Last Record!"
      Else
        DoCmd.GoToRecord , , acNext
      End If
    End Sub
    
    Private Sub cmdPrevious_Click()
      If CurrentRecord = 1 Then
        MsgBox "You are on the First Record!"
      Else
       DoCmd.GoToRecord , , acPrevious
      End If
    End Sub


    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. need to check a field for previous record in form
    By clemdawg in forum Programming
    Replies: 1
    Last Post: 06-13-2012, 07:17 PM
  2. Replies: 15
    Last Post: 05-24-2012, 02:36 AM
  3. Moving to new record from a different form
    By liam_898 in forum Forms
    Replies: 12
    Last Post: 05-05-2012, 12:34 PM
  4. Replies: 4
    Last Post: 09-09-2011, 10:00 PM
  5. Replies: 2
    Last Post: 11-04-2009, 09: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