Form Undo Problem

G

Guest

Hi

I have a form with 3 subforms. Form has a Cancel button to undo all the
changes. The problem comes when my main and subform has some new data
entered. Access savea the data before loosing focus, so when I move focus
from main to a child form, it saves my main form and on pressing button it
again moves focus to the main form so save subform :-( I can delete the
currently added record which works for addition of a new record but what
about editing the existing record. It again saves but deleting is not an
option here. First I was trying to use BeginTrans, CommitTrans, Rollback
Methods of a workspace object. I had a global variable of type workspace
which is set in OnLoad event of form to DBEngine.Workspaces(0). After this
when user press Add or Edit buttons I use MyVariable.BeginTrans to start the
transaction. But MyVariable.RollBack in my cancel button, didn't work. I
don't know if I was doing right or even if it was possible. Thie problem I
can think of is because of the scope if MyVariable.
Then I tried to use RecordsetClone to make a copy of recordset to restore it
later, but it appears that Clone just stores the refereneces and not the
actual values so when the actual values are changed, clone values are changed
too.
Next Now I will try to make an array of fields to store previous values,
which I can think of my last option. Any other ideas of doing this??
Any help would be appreciated.
Rashid
 
G

Graham R Seach

As far as I know, the only way to do that is to control the subforms'
recordsets from the main form, and wrap the whole lot in a transaction.
There is detailed instructions on how to do that in the Access 2000
Developer's Handbook, by Getz et al.

Regards,
Graham R Seach
Microsoft Access MVP
Canberra, Australia
 

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

Top