DoCmd.Save Problem with multiple users

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BobS
    New Member
    • Jul 2010
    • 10

    DoCmd.Save Problem with multiple users

    Recently traced this problem: When multiple users are using an Access application I developed. A runtime error of 2501 occured in this code when the user tried to save a record:
    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    'Provide the user with the option to save/undo
    'changes made to the record in the form
    
        If MsgBox("Changes have been made to this record." _
            & vbCrLf & vbCrLf & "Do you want to save these changes?" _
            , vbYesNo, "Changes Made...") = vbYes Then
                DoCmd.Save
            Else
                DoCmd.RunCommand acCmdUndo
        End If
    End Sub
    Error occured on the DoCmd.Save command. This does not occur if only one user is in the application. Any suggestions why this is occuring?
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32648

    #2
    Before we even start, let's have the error message posted shall we.

    Comment

    • Robert Schnebly

      #3
      The error message was a 'runtime error 2501'. This is occuring on the DoCmd.Save command. Since posting this, I've learned that this command does not save the current form you are on. Someone on another site had given this as an example of doing it this way incorrectly. I was trying to give the user a chance to make the change or cancel it. I am still looking at a way at doing this.

      Comment

      • munkee
        Contributor
        • Feb 2010
        • 374

        #4
        If you are looking for a confirmation to save changes or not then use the following article:



        I could have explained without but I think this is written really well and quite visual.

        Good luck

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32648

          #5
          Bob, Please post using your account if you have one.

          As for your problem, the event procedure the code is within, is Form_BeforeUpda te. This means that the record will be saved automatically unsless you specifically set the Cancel parameter as True (which enables the operator to get another go at it) or you clear the changes themselves using Call Me.Undo, which allows the process to continue but simply without the changes being saved.

          Doing a .Save call from within that particular event procedure makes no logical sense, as it will save anyway if simply left alone (Hence the error message).

          Comment

          • roclafamilia

            #6
            Helpful blog, bookmarked the website with hopes to read more!

            Comment

            Working...