Prevent the next button to create new record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tanya68
    New Member
    • Apr 2008
    • 3

    Prevent the next button to create new record

    I use a "next button" to enable user to cycle the data in a form. Behind the click_button I just use runcommand. But i need to prevent this button to create new record - when it arrived at last record. Please help me.
  • mshmyob
    Recognized Expert Contributor
    • Jan 2008
    • 903

    #2
    Try the following in the ON CLICK event of the button

    [code=vb]
    On Error GoTo ErrorTrap
    DoCmd.GoToRecor d , , acNext

    ErrorTrap:
    Select Case Err.Number
    Case Is = 2105
    MsgBox "End of Records"
    Case Else
    MsgBox (Err.Descriptio n & vbCrLf & Err.Number & vbCrLf & Me.Name)
    End Select
    [/code]

    cheers,

    Originally posted by tanya68
    I use a "next button" to enable user to cycle the data in a form. Behind the click_button I just use runcommand. But i need to prevent this button to create new record - when it arrived at last record. Please help me.

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      I believe for that code to work, the form's AllowAdditions Property also has to be set to No.

      Welcome to bytes!

      Linq ;0)>

      Comment

      • mshmyob
        Recognized Expert Contributor
        • Jan 2008
        • 903

        #4
        You are right Linq - I forgot to mention that. I always turn that off and have a button to let a user make chnages or add or delete just so they don't do anything by accident. That way I can have things bound without them changing things without a concerted effort on their part.

        cheers,


        Originally posted by missinglinq
        I believe for that code to work, the form's AllowAdditions Property also has to be set to No.

        Welcome to bytes!

        Linq ;0)>

        Comment

        • missinglinq
          Recognized Expert Specialist
          • Nov 2006
          • 3533

          #5
          Me, too, that's how I spotted it! I actually run all my apps full screen with pretty much everything turned off, using custom buttons to do everything.

          Linq ;0)>

          Comment

          • tanya68
            New Member
            • Apr 2008
            • 3

            #6
            Originally posted by missinglinq
            I believe for that code to work, the form's AllowAdditions Property also has to be set to No.

            Welcome to bytes!

            Linq ;0)>
            So nice of you ! Thank you..your advise is working now ! And the answer is incredible fast.....!

            Comment

            • tanya68
              New Member
              • Apr 2008
              • 3

              #7
              Originally posted by mshmyob
              Try the following in the ON CLICK event of the button

              [code=vb]
              On Error GoTo ErrorTrap
              DoCmd.GoToRecor d , , acNext

              ErrorTrap:
              Select Case Err.Number
              Case Is = 2105
              MsgBox "End of Records"
              Case Else
              MsgBox (Err.Descriptio n & vbCrLf & Err.Number & vbCrLf & Me.Name)
              End Select
              [/code]

              cheers,
              Thanks a lot ! it's working ! The help that immediately arrive....thank a lot !

              Comment

              • mshmyob
                Recognized Expert Contributor
                • Jan 2008
                • 903

                #8
                Well you know what they say .... "Great minds think alike".... or is that ... "Fools seldom differ".

                cheers,


                Originally posted by missinglinq
                Me, too, that's how I spotted it! I actually run all my apps full screen with pretty much everything turned off, using custom buttons to do everything.

                Linq ;0)>

                Comment

                • mshmyob
                  Recognized Expert Contributor
                  • Jan 2008
                  • 903

                  #9
                  You're welcome, glad we could help.

                  cheers,

                  Originally posted by tanya68
                  Thanks a lot ! it's working ! The help that immediately arrive....thank a lot !

                  Comment

                  Working...