P
Peter Hallett
Access seems to suffer from a major defect (correct me if I am wrong). If a
form is bound to a table then there appears to be no simple way of abandoning
any subsequent data entry. Whatever method of exit is chosen, the contents
of the form are saved to the bound table when the form is closed. (It was
pointed out to me by one of this newsgroup’s MVPs that ‘No Save’ does not
mean what I, and many others, I gather, assumed it to mean, until disabused
of the misapprehension.)
This can be a serious limitation. If, for example, extensive amendments are
made to an employee’s personal record, only to discover, at a late stage,
that the changes have been carried out on the wrong record, then the logical
way to rectify the situation would be to abandon the form and start again but
that does not seem to be possible. The alternative is to return all the
fields to their original values before closing the form but that is often
impractical, or at best very inconvenient – even for those with a good memory.
I have frequently overcome the problem by copying selected records to a
buffer table, using an append query, then binding the form to that buffer
table. Aborting data entry is then easy. On closing the form, its fields
are saved to the buffer table which can then be deleted without affecting the
source table. If the values are to be saved, then the source table is
updated from the buffer table using one or more update queries but this is
not always the most appropriate solution. With a continuous form bound to a
whole table, for example, rollback might be a more satisfactory technique,
starting a transaction, based on the bound table, when the form is opened,
and presenting the options of either committing the transaction or rolling it
back when data entry is complete – but I cannot get this to work. I have
studied the example accompanying the Help topic ‘BeginTrans, CommitTrans,
Rollback Methods’ but although the code I have written, based on this
example, compiles and runs without complaint, it does nothing. Whatever I
do, all fields modified on a form are always saved back to its bound table.
Can some kind soul please help, ideally with a few lines of VBA?
form is bound to a table then there appears to be no simple way of abandoning
any subsequent data entry. Whatever method of exit is chosen, the contents
of the form are saved to the bound table when the form is closed. (It was
pointed out to me by one of this newsgroup’s MVPs that ‘No Save’ does not
mean what I, and many others, I gather, assumed it to mean, until disabused
of the misapprehension.)
This can be a serious limitation. If, for example, extensive amendments are
made to an employee’s personal record, only to discover, at a late stage,
that the changes have been carried out on the wrong record, then the logical
way to rectify the situation would be to abandon the form and start again but
that does not seem to be possible. The alternative is to return all the
fields to their original values before closing the form but that is often
impractical, or at best very inconvenient – even for those with a good memory.
I have frequently overcome the problem by copying selected records to a
buffer table, using an append query, then binding the form to that buffer
table. Aborting data entry is then easy. On closing the form, its fields
are saved to the buffer table which can then be deleted without affecting the
source table. If the values are to be saved, then the source table is
updated from the buffer table using one or more update queries but this is
not always the most appropriate solution. With a continuous form bound to a
whole table, for example, rollback might be a more satisfactory technique,
starting a transaction, based on the bound table, when the form is opened,
and presenting the options of either committing the transaction or rolling it
back when data entry is complete – but I cannot get this to work. I have
studied the example accompanying the Help topic ‘BeginTrans, CommitTrans,
Rollback Methods’ but although the code I have written, based on this
example, compiles and runs without complaint, it does nothing. Whatever I
do, all fields modified on a form are always saved back to its bound table.
Can some kind soul please help, ideally with a few lines of VBA?