• Previos/Next Buttons (2002-SP3)

    Author
    Topic
    #444929

    I have buttons on a form to go to previous and next records.

    How can I stop the next button from going to create a new record when it gets to the end of the records.
    Here is the code for the button DoCmd.GoToRecord , , acNext

    If you click on the next button one more time you get a message that says that you can’t go to the specified record. That’s what I want instead of switching to a new record.

    Thanks

    Paul

    Viewing 1 reply thread
    Author
    Replies
    • #1077311

      Set the form property Allow Additions to No.

    • #1077312

      If you set the Allow Additions property of the form to No, the user won’t be able to create a new record.

      If you add

      On Error Resume Next

      at the beginning of the code, the user won’t get an error message if the button tries to go past the last record.

      • #1077314

        Hans-

        I don’t thin that solves my problem.

        I want the message – I just don’t want it to go to new record before I get the message.

        Paul

        • #1077319

          Why doesn’t setting Allow Additions to No solve your problem? It’ll prevent the user from going to a new record.

          • #1077331

            That won’t work because I do have a button on the form to add new records. I just didn’t want the next button to take you to that screen.

            • #1077333

              You can set AllowAdditions to True in the On Click event of your “Add record” button, before moving to the new record.
              Then set it to False again in the On Current event of the form.

            • #1077353

              That will work.

              Thanks.

              Paul

    Viewing 1 reply thread
    Reply To: Previos/Next Buttons (2002-SP3)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: