If there is a need to add records in two different tables to accomplish one
goal, that can be a matter of using a transaction. If there is a need to add
12 records in one table, that may be better to use ONE insert query (which
will be almost like one atomic operation) but if that cannot be done and
looping need to be done, then, that may also become a good case to make a
transaction between the start and the end of the loop.
Transaction should be short. If there is a step that requires a user
intervention, inside the transaction, that is *probably* not very good (CAN
be too long, the user may have left for lunch) since tables and records may
become locked. With Jet, you don't get much control on what kind of
'isolation' (what other users can see about your transaction, even if they
can delete or append records on tables you just 'took a look at' , in your
transaction) you have, in comparison with MS SQL Server, but note that you
can indeed lock other users out of tables and records you touched: that is
an inconvenient about transaction, for these other users (or your own access
to the data though other means than through your transaction).
The user interface uses a transaction when you insert a bunch of data into a
table. Indeed, when you get the prompt about nnn records won't be added for
this or that reason, the prompt (user intervention ! ) is about accepting
the records that are not in 'error', or to abort the whole insertion thing.
This *is* a transaction that the interface started for you, and asked you
about committing it, or rolling it back! Inserting a bunch of data and
having to validate it is, indeed, a good example for a transaction. If you
have to 'touch' many tables (or the same table many times) and cannot do it
in one single query, that is typical example where a transaction can be
useful. Note that the operation system can also supply its own
transaction-thing when components outside a database may be involved (bank
transfer of money, as example), but that is, here, out of scope, even if it
is interesting to know that such thing is available.
Vanderghast, Access MVP