Write Conflict - record changed by ???

M

Max Moor

Hi All,
I have a form with two subforms. The main form only has a combobox
for selecting which record to view. Two views of the data are possible, by
viewing one subform, and having the other be hidden.

Both subforms define their recordset by an SQL statement which is then
filtered to a single record when the main form's combobox is updates.

Finally, both subforms include a pair of text boxes that each display
a field in the record. These are enabled or not based on a yes/no that is
also in the datarecord. The code that updates them when subforms' yes/no
checkbox is changed is below.

What I really want is for the boxes to automatically enable or disable
themselves based on the yes/no's. I first tried doing this in the
OnCurrent event for the subforms. I got Write Conflict errors.

I thought, apparently incorrectly, that doing it in the OnCurrent
event was the problem. I added a Public wrapper function in the subforms'
modules, so I could call the update functions from the mainform combobox
update sub. Guess what? I still have Write Conflict erors.

Have I given enough info so that someone can explain this to me?

Thanks, Max



' This code enables or disables the salutaion textbox based
' on whether or not the users want to use the system generated
' salutaions or ones they define thewmselves.

Private Sub chkSalutationOverride_AfterUpdate()
If (Me!chkSalutationOverride = True) Then
Me!txtSalutation.Enabled = True
Else
Me!txtSalutation.Enabled = False
Me!txtSalutation = Me!FirstName
End If
End Sub
 
S

Sylvain Lafontaine

You are not only enabling/disabling a control in the OnCurrent event, you
are also changing the value of the txtSalutation field.

I suppose that this field is present in both subforms, hence your write
conflict: when you leave the current record, both subforms will update their
data; however, when the first subform has finished updating its data, the
data stored in the BE are no longer what they were when the second subform
has retrieved its own data so when this second subform will try to update
its own data after the first subform, the Write Conflict will happen. This
is because of the "optimistic locking" used by Access: all forms/subforms
make the verification that the data has not been changed by someone else in
the meantime when they make an attempt to update the data and they won't
make any difference between another form (or subform) or someone else.
 

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

Top