The short answer is that you can't. One of the good (and bad) things
about Access is the ease with which you can develop and run apps.
There are not a lot of "manual" things to be done. Like "Save" buttons
and so forth. Many times, when entering a new record, the data is
saved to the table "before you would think it is".
If you have entered a new main record, gone to a subform and entered
new related records, returned to the main form. You have already
commited that data, and Access has no easy way to back you out of
this transaction.
You can put a "Cancel Transaction" button. When pressed the button
can:
Delete all child Records:
Code:
DoCmd.RunSQL "Delete From MyChildTable Where ChildKey = " & Me.MainKey
Then delete the current Main Record.
Code:
DoCmd.RunSQL "Delete From MyMainTable Where MainKey = " & Me.MainKey
You should establish proper relationships between tables so you can enforce Referential Integrity and avail yourself of the Cascade Delete option. Cascade Delete will delete all order details when you delete an order so you don't have to run two queries.
I already setup proper relationship with cascading deletion, so it does gets deleted. What I wanted to do is not even save it to the table to start with.
but I guess i am use to SQL Server transactions, were u can undo the transaction altogether.