Results 1 to 9 of 9
  1. #1
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727

    Next Record Button

    I have a button to navigate to the next record. I also have a button to add a new record. I want the next record button to be able to navigate to the next record but I don't want it to be able to create a new record if I click the button while being on the last record. I want it to stop at the last record, making my add a new record button the only way to create a new record.

    Does anyone know how to do that?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Options:

    1. Set the form Allow Additions property to no and code behind the Add Record button manages allowing new record

    2. Code behind Next button checks if the current record is the last record of the form recordset
    If Me.CurrentRecord <> Me.RecordCount Then
    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
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    I'm not good with the codes. Is there a specific code you can suggest for the Add Record button? And do I put the code on an event like "On Click"?

    The code for the Next button, is that all I need? Where do I put it? In an event?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Code goes in the button Click event.

    You don't already have code behind these buttons?
    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.

  5. #5
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    I have code behind the buttons but it is the default code that is used through the button wizard so I did not manually add any code myself. So if I understand correctly, the code you provided is the only thing I need to add to the Next Record button? Does it have to be the first action? Or can it be the last action?

    Since we are on the subject of buttons, I was wondering if you would have the answer to another situation I am having. I have created a button for Find Record. By default, it works but the thing I don't like about it is that you need to click on the field that you want to search. The "Look in" part of the search only allows for me to choose the field I am currently in. Is there a way so that the search box lists all fields in the "Look in" section? I hate having to make sure I click on the field box that I want to do a search in every time.

  6. #6
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    Ok I tried this just now and I don't think I did the code correctly because I do not know how to add that into the button. The Allow Additions property set to No stopped the next record button from creating a new record, however, it also stopped the Add New Record button as well.

    When adding the code you mentioned: If Me.CurrentRecord <> Me.RecordCount Then
    Where do I put it? I tried adding it in the On Click event but there is already an action listed that was there by default when creating the button using the wizard. So I tried typing it into the action field but I'm not sure that's how you are supposed to add it.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What do you mean by 'action field'? The Click event property box on the Property Sheet? Do not type code there. VBA code goes in the VBA editor. Can type code into any procedure, even if generated by wizards (I don't use the wizards).
    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.

  8. #8
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    The code you provided seems to be incomplete. Is there any chance you have the whole thing to make this work?

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    That was only the first line of the procedure. The rest could be like:

    If Me.CurrentRecord <> Me.RecordCount Then

    'your code to move to next record

    Else

    'do something, maybe just a message box
    MsgBox "This is the last record."

    End If
    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.

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

Similar Threads

  1. Replies: 1
    Last Post: 06-24-2013, 11:31 AM
  2. Replies: 22
    Last Post: 06-12-2012, 10:02 PM
  3. Replies: 4
    Last Post: 07-22-2011, 12:52 PM
  4. Replies: 10
    Last Post: 03-21-2011, 02:46 PM
  5. Replies: 6
    Last Post: 02-09-2010, 07:53 AM

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