Pasting multiple records into a form

  • Thread starter Thread starter Jeremy Saul
  • Start date Start date
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
 
Jeremy,

Another possibility is to use a temporary table to add / paste new
records, and then use a command button on the form to fire code to make
the additions to both tables (through recordset operation or Append
queries, either saved or in SQL in your code) and clear the temp table.

HTH,
Nikos
 
Back
Top