RunTime Error 2501 when saving changed data in a form....

P

PaulHilgeman

Now that I have added users etc. to my database I get errors every time
I try to save data wether I am logged in as the admin or not.

The event is an BeforeUpdate Event that obviously runs anytime a user
tries to exit the form, by either closing or searching for a new record
when they have made changes.

The funny thing is that it worked fine before I went through the whole
users and security ordeal.

Here is the code:
**************************************************************************************
Private Sub Form_BeforeUpdate(Cancel As Integer)
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
**************************************************************************************
Any help would be apreciated. Thank you!!!!
 
P

PaulHilgeman

More Data:

Now it seems as though only one user can be logged into the database at
any given time. How do I change out of this "exclusive mode"?

Also could it be stemming from the fact that I am using several macros
on the form that on an event (like a GotFocus on a radio button) it
will print the current user name in a textbox?

Hmmmm, I am really confused by this one.

Thanks,
Paul
 
A

Allen Browne

DoCmd.Save does not save the record: it attempts save design changes.

Access fires the BeforeUpdate event of the form just before the record is
saved. You therefore need to take *no* action to save the record. If you
want to prevent the save, you cancel the event. So:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Changes have been made to this record." _
& vbCrLf & vbCrLf & "Do you want to save these changes?" _
, vbYesNo, "Changes Made...") = vb No Then

Cancel = True
Me.Undo

End If
End Sub

The setting that determines whether a user opens the database exclusively by
default is:
Tools | Options | Advanced | Default Open Mode

If you have multiple users in the one mdb, you need to split it so the
shared data is separate from the local front end. It that is a new idea,
see:
Split your MDB file into data and application
at:
http://allenbrowne.com/ser-01.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top