How to resolve the write conflict message (or something similar): "This record has a table. changed by another user since you started editing it. ..." when only one person is using the database.
A write conflict in a form used by a single user is created when another process saves to a record while a form bound to that record is dirty. The other process could be another form (or subform), an action query or a recordset. For example: a user inputs data into a form bound to a table. This makes the form dirty but does not enter the changes into the table. In the code of the form, an update query changes the same record the form in bound to. With this action, a potential write conflict is created. The user then enters some additional information in the form. When the user moves to another record, the dirty record tries to write to the table but Access doesn't know which information is correct: the information in the form or the information in the table which was changed while the data in the form was being changed (but was not yet saved). So when the form tries to write to the table, the write conflict message pops up. Notice that the problem was created when the update query ran, not when the message popped up.
To avoid this error, you need to save the dirty form before writing to the record with another process. The best way to save a dirty form is to use the line
Me.Dirty = False
This line saves the current record and makes the form clean. It runs into fewer problems than other record save statements like RunCommand acCmdSaveRecord. The hardest part is figuring out where to put that line. As stated earlier, it needs to go BEFORE the other process writes to the same record the form is bound to. Look for action queries and editing recordsets in your code that is running. If you have two forms open to the same record, then, definitely, you have to save the dirty record before changing the focus to the other form.
There are two techniques that will help figure out where the problem is occurring, 1. If the write conflict message has a save to clipboard option, click on it. Open Notepad and paste in the clipboard information. The information may give you a hint of where to place the Me.Dirty = False statement. 2. Open a select query displaying the record the form is bound to. Single step through your code (or faster, run small blocks of code using Debug, Run to Curser) while watching the query for changes. A select query shows changes immediately while an opened table needs to be refreshed to show changes.
There is no need to use the if statement with Me.Dirty = False like this:
If Me.Dirty = True Then Me.Dirty = False 'NOT NECESSARY
If the form is clean, Me.Dirty = False does nothing.
References:
http://support.microsoft.com/kb/837937http://support.microsoft.com/kb/304181