undo changes

  • Thread starter Thread starter jon
  • Start date Start date
J

jon

Hi
I have a form which is opened with a record in, but I want a button to undo
any changes which have been made since the form was opened.

The line

DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70

does not work as it says the command or action 'undo' isn't available now.

I am using access 97

any advise is appreciated.

Jon
 
There is not a simple way to do that, Jon.

Access saves each record as soon as you move to another one. To undo all
changes made since you opened the form is not something it supports.

In Access 2000 and later, it is possible to programmatically open a
transaction, open a Recordset inside the transaction, and assign this
Recordset to the Recordset property of the form. When the user is ready to
close the form, you can then decide to commit or rollback the transaction.

In practice, there are several problems with that approach:
- Haven't tested recently, but I did find this approach to be unstable (i.e.
Access is likely to crash)

- Subforms don't work properly. As you change record in the main form,
Access loads the matching records for the subform, so you can't use a
Recordset as the source for the subform, and consequently it doesn't roll
back.

- There are multi-user issues with multiple sustained transactions like
that.

Another alternative is to copy the records into a local temp table, and
write them to your real table only when the user wants to commit them. The
biggest problem here is the fact that multiple users have disparate copies
of the temp table, which is not simple to synchronize.

So - in essence - no, you can't do that easily.
 
ok
thanks for that

Jon
Allen Browne said:
There is not a simple way to do that, Jon.

Access saves each record as soon as you move to another one. To undo all
changes made since you opened the form is not something it supports.

In Access 2000 and later, it is possible to programmatically open a
transaction, open a Recordset inside the transaction, and assign this
Recordset to the Recordset property of the form. When the user is ready to
close the form, you can then decide to commit or rollback the transaction.

In practice, there are several problems with that approach:
- Haven't tested recently, but I did find this approach to be unstable
(i.e. Access is likely to crash)

- Subforms don't work properly. As you change record in the main form,
Access loads the matching records for the subform, so you can't use a
Recordset as the source for the subform, and consequently it doesn't roll
back.

- There are multi-user issues with multiple sustained transactions like
that.

Another alternative is to copy the records into a local temp table, and
write them to your real table only when the user wants to commit them. The
biggest problem here is the fact that multiple users have disparate copies
of the temp table, which is not simple to synchronize.

So - in essence - no, you can't do that easily.
 
Back
Top