Undo Command

B

Bumbino

I have a form with an embedded subform. On the main form, I have a cancel
button that performs ME.Undo. I would like to get it to also Undo the
entries on the subform but cannot get it to work. Any ideas??
 
S

Stuart McCall

Bumbino said:
I have a form with an embedded subform. On the main form, I have a cancel
button that performs ME.Undo. I would like to get it to also Undo the
entries on the subform but cannot get it to work. Any ideas??

Me.SubformControlName.Form.Undo
 
D

Dirk Goldgar

Bumbino said:
I have a form with an embedded subform. On the main form, I have a cancel
button that performs ME.Undo. I would like to get it to also Undo the
entries on the subform but cannot get it to work. Any ideas??


Once the focus moves back to the main form from the subform, the subform's
record will automatically be saved (if it has been modified). There's
really nothing much you can do about this, so by the time you click your
button on the main form, it's too late to undo the record on the subform.
You might try using a button on a custom command bar instead. You should be
able to undo both the subform and the main form from there. You still won't
be able to undo multiple records on the subform, if that was what you had in
mind; only the record that is currently unsaved.

If you need to undo multiple records on the subform, your best bet is
probably to base the subform on a temporary table, so that you can just
discard all the records in that table, or else accept them by copying them
into the "real" table.
 
J

John W. Vinson

I have a form with an embedded subform. On the main form, I have a cancel
button that performs ME.Undo. I would like to get it to also Undo the
entries on the subform but cannot get it to work. Any ideas??

The problem is that it's TOO LATE.

The instant you set focus to the main form by clicking the button, the dirty
record (if any) on the subform will be saved to disk. If the user has entered
328 records on the subform, all 328 will have been saved to disk. They cannot
be undone.

You will need to run a Delete query to delete the records (and hope that no
other user has been printing them out, reading them, doing calculations using
them, editing them, etc.)

John W. Vinson [MVP]
 
B

Bumbino

Thanks guys. It looks like I will use Dirk's idea of the temp table since I
wouldn't know how to code John's idea of the query. Thanks again.
 

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

Similar Threads


Top