By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,930 Members | 1,383 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,930 IT Pros & Developers. It's quick & easy.

Undo in MS Access

P: 23
Hello everybody
I have a question for which I have search net for last 3 hours but could not find answer.
I have an entry form over which I have placed an 'undo' button with following code
Expand|Select|Wrap|Line Numbers
  1. Private sub cmdUndo_OnClcik()
  2. If Form.Dirty Then
  3.  DoCmd.RunCommand acCmdUndo
  4. Else: Exit Sub
  5. End If
  6. End sub
It works fine..
Now I come to the question that I find answer of;
When Its new record and I press Undo button after some entering data in some textbox controls, it deletes all record, because when I enter data again, Primary ID gets changed.
what I guess that its is because undo deletes all entries that has not been saved.
With this all in background, is there any way that undo deletes or erases data only from that control, in which it was entered just before pressing undo. And if its not possible, then is it possible that undo does not delete the record altogether and preserves primary ID?
Please help me find the answers
Dec 10 '13 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 5,397
you've give scant information about how your form is designed and worse, what you have given is along the lines of "stream of conscense" which is hard for most people to follow.

From what I can tell,
The form is bound, either via query or directly to the table.
The primary-key is most likely an auto-number field.

IFF both are true then there is no way to preserve the autonumber once a record is started. It doesn't matter what method of undo is used, once new-record becomes dirty the next autonumber in sequence is assigned to the field and the index incremented. This is why all of the Experts here tell our members NOT to use the autonumber for anything other than a unique record id. If you need sequential numbers then there are methods such as DMAX()+1.

As for clearing the controls, most will have an undo for edited but not for new entries as a new entry was NULL() at inception unless a default value was assigned.
Dec 11 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.