Question Write conflict error in access

Milad Roohi

New member
Local time
Today, 14:41
Joined
May 27, 2016
Messages
5
Hi, have nice day
I'm new in access and have problem with write conflict error, I use this code for update my table :

cmd = "UPDATE TblStudent SET Student_Image = '" + fileName + "' WHERE Student_ID_ = " + Student_ID
DoCmd.RunSQL cmd

But everytime i face with this error :

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.
Then, you can click one of the following three buttons:
1.Save Record
2.Copy To Clipboard
3.Drop Changes

what can i do to not see this and run my sql code correctly??

thanks
 
You probably are on the record on the form, or sub form, that you are trying to update. Save or refresh the record before doing the update statement.
 
Hi, have nice day

cmd = "UPDATE TblStudent SET Student_Image = '" + fileName + "' WHERE Student_ID_ = " + Student_ID

note that in the above, string concatenation should use & rather than plus +

most of the time it might not matter, but in some cases + will not work correctly.
 
You probably are on the record on the form, or sub form, that you are trying to update. Save or refresh the record before doing the update statement.

yes exactly that's the problem but what can i do to get rid of this??
 
You need to Save the record before running your update statement. You can use the Dirty Property as a quick way to save a changed record;

If Me.Dirty Then Me.Dirty = False
 

Users who are viewing this thread

Back
Top Bottom