Problem pasting multiple records into a form using VBA

J

Jeremy Saul

I have a continuous form that I use to display and edit the fields of a
single table. When I add a record I need to add a record to a related table
to maintain consistency and relational integrity. To do this I have used the
After_Insert event procedure on the form to add the record I need to the
other table using a DAO recordset and the Add and Update methods.

All this works fine when I add a record. It also works fine if I copy and
paste a record as a new record. The problem comes if I copy and then paste
multiple records as new records. The Update method on the other
recordset/table fails with an error "data is being updated by another user"
(or something similar). It is as though their are multiple AfterUpdate
events running in parallel. In any event, how can I find the details from
the two records that are being pasted?

As I see it there are several possible solutions.
1. Find some way to serialise the pasting of the multiple records.
2. Restrict the paste operation to only allow a single record to be pasted
3. Prevent the form allowing the paste operation at all, yet still be able
to add new records individually from newly entered data.

Any advice on any of these possible solutions, or the problem in general
(like how to avoid it completely) would be appreciated.

Jeremy Saul
 

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