Write conflicts - why?

T

Tom Symonds

I recently added a feature to my database that does the following:
Kept a count of the number of times I had opened a record (AccessCount -
numerical field)
Added 1 every time I opened the record -- Visual Basic code in the On
Current event property of the form.
Once a record had been opened three times it creates a little Wingdings icon
in a 1 character text field to show it is a 'favourite'. This icon is
displayed in other forms.

The problem I have is that since making these changes I sometimes get a
"write conflict error" -- because "another user was editing this record". I
can't work out why -- the database is on a network, but no-one else accesses
it but me.

I thought it might be because I was 'automatically' making an edit in the
record -- by advancing the AccessCount field.

Any thoughts?
 
K

Ken Snell

If you are trying to update the AccessCountField while you're still editing
the record, and assuming that you're doing that update via VBA code (update
query or recordset), then you are the person who has is editing the record
when your code tries to run. I suggest that you put the field for the
AccessCountField on your form (make it invisible) and then just write the
new value into it with your code. That way, you'll not see the write
conflict error.

Otherwise, you'll need to do your updating after you've saved the record to
the table so that no conflict will occur.
 
T

Tom Symonds

Thanks thats useful.

The field is already on the form and the update takes places on the ON
Current event. Should I put it on a different event -- which one triggers
AFTER you save the form?
 
T

Tom Symonds

Can anyone advise on this:
The field is already on the form and the update takes places on the ON
Current event. Should I put it on a different event -- which one triggers
AFTER you save the form?
 
K

Ken Snell

The form's AfterUpdate event will occur after the record is saved to the
underlying RecordSource's table/query. The OnCurrent event runs whenever the
form opens/loads and whenever you move from one record to another. I've
noted at times that there can be conflicts with OnCurrent when trying to use
saved info.

Not sure what you mean that the field is already on the form -- do you mean
a control that is bound to the AccessCountField field? Or do you mean that
the AccessCountField is part of the form's recordsource but that you have no
control on the form that is bound to it? I mistyped in my reply when I said
to put the field on your form -- what I meant to type is to put a control on
the form, bind it to that field, and make the control invisible.
 
T

Tom Symonds

Before I saw your reply I moved the code to the OnUnload event and that
seems to have fixed it.

I have a control on the form, bound to AccessCount and made invisible.

Thanks for help
 

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