Write Conflict warning

R

rwfreeman

Access 2003. I'm using the OnClick event of a subform to change the
value of a checkbox. The ControlSource for the subform is an SQL
statement on an existing table. The database has no communication
with a network.

The first click on a record in the subform changes the checkbox as
desired. However, any subsequent click on the subform or any control
on the parent form produces a "Write Conflict" warning in a dialog box
that states "This record has been changed by another user since you
started editing it. ... " There are three choices in the form of
buttons which have the following captions "Save Record", "Copy to
Clipboard", "Drop Changes". This warning occurs before any change is
made to the checkbox. If I click on the "Drop Changes" button, the
message clears and if I click on the subform's record again, the
checkbox is changed. I've tried surrounding the contents of the
OnClick event with "DoCmd.SetWarnings False" and "DoCmd.SetWarnings
True" but the Write Conflict message still appears. There is no
"another user" on the database, so I'm at a loss as to why this is
occurring. Help would be appreciated.

Richard Freeman
 
A

Albert D. Kallal

that other user is your code!!

Ms-access does not really know if you, or some other user or some other code
has changed a record in a form.

However, what ms-access does is if the current record in the form is "dirty"
(that means pending write will occur when you move to another record, close
the form).

So, you have a table record, and a form record, but the form record has NOT
BEEN written to disk.

So, the simple solution here is to commit your record to disk BEFORE you
potentially run any code, or any sql that might modify the current record.

The most easy way to commit the current record to disk is simply go:

if me.Dirty = true then
me.Dirty = false
end if
.... you update (sql) code follows here.....

So, either don't run code that will modify the SAME record that has pending
writes, or simply do the above.

This also happens quite frequently when you have a continues form that
displays records, and you have a button to launch a "details" form that for
that same record. So, simply commit the record from the form to disk beofre
you run that update code.....and your conflict should go away...
 
R

rwfreeman

that other user is your code!!

Ms-access does not really know if you, or some other user or some other code
has changed a record in a form.

However, what ms-access does is if the current record in the form is "dirty"
(that means pending write will occur when you move to another record, close
the form).

So, you have a table record, and a form record, but the form record has NOT
BEEN written to disk.

So, the simple solution here is to commit your record to disk BEFORE you
potentially run any code, or any sql that might modify the current record.

The most easy way to commit the current record to disk is simply go:

if me.Dirty = true then
me.Dirty = false
end if
... you update (sql) code follows here.....

So, either don't run code that will modify the SAME record that has pending
writes, or simply do the above.

This also happens quite frequently when you have a continues form that
displays records, and you have a button to launch a "details" form that for
that same record. So, simply commit the record from the form to disk beofre
you run that update code.....and your conflict should go away...

Thanks for the fix AND explanation. Adding the "If Me.Dirty Then ...
" code to the OnClick event of the subform made the conflict warning
go away.
 
M

Mail96

Hi,

Tried this and I'm still getting the same error.

I have a main form which goes to a more detailed form that is linked to an
oracle DB via ODBC. Updates in some records on the detailed form will
generate the write conflict warning, but not all updates/saves produce this
problem. I compare the data from the record that recieve the write conflict
warning, and one that does not, and found no data type differences in the two
records.

In the on click event, I added the me.dirty = false right away, and it's
executes fine. The warning appears Immediately after I update a couple of
columns in the record, the write conflict warning appears.

The codes are as follows in the on click event

If Me.Dirty = True Then
Me.Dirty = False
End If

Me![COMMENT] = "testing"
Me![STATUS] = 1
' => error appears when it hits the line below.
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

I have added to the same code on the main form under "on deactivate" hoping
this will solve the problem, but it did not.

Any help would be greatly appreciated.

Thank you.
Bonnie
 

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