Solved Write Conflict on record when closing (1 Viewer)

Lochwood

Registered User.
Local time
Yesterday, 20:14
Joined
Jun 7, 2017
Messages
105
I have a date field on a form and VBA after update event if the date field is null it ticks a box, if it is not null it unticks the box.. code works but when i close form it gives me a write conflict.. someone else has changed the record. I have also tried adding me.dirty=false at the start and end of code.

Any thoughts?
 

namliam

The Mailman - AWF VIP
Local time
Today, 05:14
Joined
Aug 11, 2003
Messages
11,680
Why create a tick box to "calculate" something that can very easily be done either on the fly or can just simply be selected on the table

??

Solution: Not do it this way.
 

Lochwood

Registered User.
Local time
Yesterday, 20:14
Joined
Jun 7, 2017
Messages
105
The tickbox is a field on the table. before this was a manual tick but i am trying to get the code to tick it for me based on the condition of the date field. i was going to discard the tick box completely and have a calculated field on the query showing result but thought i would accommodate the tick box
 

arnelgp

error reading drive A:
Local time
Today, 12:14
Joined
May 7, 2009
Messages
10,871
do not use SQL to Update the table. Use your Form's Recordset.
The reason is that if you edit the record in Form (the record is but a Snapshot) and
you use SQL to update the underlying table again, the physical table (the recordsource of
the form) is now Become more "Updated" than what you are trying to update in the form.
therefore, access complains.
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 23:14
Joined
Feb 19, 2002
Messages
30,148
As arne suggested, it is your own code that is causing the conflict.

If you are using the AfterUpdate event of the form, you are causing an infinite loop. Luckily, newer versions of Access recover gracefully from this rather than freezing as earlier versions did. The AfterUpdate event of the form runs AFTER the record has been saved so if you modify the record in that event, you are forcing Access to have to save the record again and that causes the AfterUpdate to run again where you dirty the record forcing Access to save the record again. Get it?

If you are using the AfterUpdate event of a control, you will only catch null values when the user clears an existing value.. But the bottom line as namliam said is to not have a check field at all. There is absolutely no difference between checking one field for null or a different field for true. So, remove the check field entirely.
 

Users who are viewing this thread

Top Bottom