Write Conflict

kirkm

Registered User.
Local time
Tomorrow, 06:51
Joined
Oct 30, 2008
Messages
1,257
Why do I get this message ??

This record has been changed by another user since you started
editing it. If you save the record, you will overwrite the changes
the other user made.
Copying the changes to the clipboard will let you look at the values
the other user entered, and then paste your changes back in if you
decide to make changes.

There are no other users and none of the 3 options make much sense to me, nor do they seem to work as indicated.

If I click Save all changes are saved which is what I want but why is it necessary? It 'd be much better if I could suppress this worrying message altogether. Is it possible ?

Thanks
 
This can happen if there is some code that is modifying the current record of the form. If there is code like that I suggest trying a form refresh in that code,i,e, Me.Refresh in in the form module or Forms!NameOfForm.Refresh if elsewhere.

Maybe you can avoid the code update by doing things differently. For example when I came across this problem my sister had a command button set up with code that would run an update statement that updated the table that was assigned as the record set of the form. To fix the problem just retrieve the value from the table and assigned in to the bound textbox on the form so it got inserted with the rest of the form data.
 
Thanks Steve, Refresh has worked. I tried to step through where it was happening but
couldn't trap it. Also tried the refresh in other places but it has to be in After Update event
that causes the problem.

Can I check some condition for needing it and apply it only then ? I found it happens once but I'm entering a batch of items so it's now refreshing after every one.

What is the 'name of Form'? Using access 2003. In the Database window it's called e.g. frmAddTracks. Then in the VBA editor Project window it's Form_frmAddTracks. Refresh would not work with either name (but only needed Me.Refresh).
 
Forms!frmAddTracks.Refresh should have worked but it's easier to use Me.Refresh when you can anyway.
 
Can I check some condition for needing it and apply it only then ?
I don't know. I've been trying to recreate this situation so I could do some testing but my test application is locking all of the records even though Record Locking is set to Edit Record.

If no other forum members addresses your question then I suggest send a message to The_Doc_Man asking him. He seems to know a lot about this sort of stuff. I'd like to know the answer to this myself. Sorry I couldn't help you on this one.
 
@sneuberg

I think you will only get this message when you do not use record locking.

optimistic locking works by assuming a write will succeed, but by re-reading the record before writing to detect a change - hence the message. If you are pessimistically locking the record you will not get this position.

Often the message is caused by programming errors, as you point out. You will get the message if 2 users (try to) edit the same record simultaneously - but you also get it is one user edits the same record twice. This can be done by editing a record in a normal form, and then using the form to open a different view of the same data, and then editing that as well. Easily demonstrated and prevented.
 
@Dave

Thanks for your response. I tried it with no locking but then I wasn't getting the message. Maybe I'm not doing it in the right sequence to get it.

Can you give us any input on kirkm's question about checking for some condition before applying the form refresh?
 
I have never quite understood the options, and have always just discarded the edit. Maybe it's saying save the record, then re-open the form to inspect how it has changed.

There are no other users and none of the 3 options make much sense to me, nor do they seem to work as indicated.

this is the point. There is definitely more than one process which has modified the record. So when either process tries to save the record they get the report that "another user has changed it. ". It might be another user, but often it happens that the other user is yourself. You must have the same record edited twice - it might be two forms, it might even be one form and a recordset. Hence it's a system design/application error

To demonstrate simply open the same record in two different (though similar) forms, make changes to both, and then try to save one.

Generally, you might have an general review form for a record, and you changed something, and then another form trying to edit a particular field in the same record - maybe a "popup" form opened by clicking a button on the same form. If you add record selectors to the form, it's easy to see the "dirty" records. Sometimes the startup code for a form can contribute to this by "dirtying" the record. It might be as easy as saving the dirty record before opening the second form. Or perhaps testing whether the first form is open before opening the second form.
 
My db was originally written by someone else, and I've messed about with it for a few years. It does cleverer stuff than I know about and my additions can be a bit hit and miss. It does involve a second Form but I can edit all fields except one and not get the error. There's no obvious reason what that causes the write conflict. BTW if I click Save it keeps my edit/addition and doesn't overwrite or change anything else.

I did check for Dirty at the after-update event and it was true all the time.
Also, the Form may display multiple rows but only the first edit has the problem. Then it's ok until the Form is next opened.

I worked out a fix, set a global boolean and

If kRefresh = True Then 'Do this only once
Me.Refresh
kRefresh = False
End If

It works, but ideally it'd be much better to know why its happening and fix it properly.
 
without seeing the dbs it's hard to see the exact reason, but I am pretty sure that if access declares "the another user issue", then something is "dirtying" the record.
 

Users who are viewing this thread

Back
Top Bottom