Undo button

G

Guest

I have an Undo Record button in my form that is working weird. I created it
using the wizard. If I press it, it will either ask if I want to delete the
record, or it will undo changes I made on another record. What am I doing
wrong?
 
A

Allen Browne

The wizard-generated undo button should not delete the record, but it can
undo another record.

The code below should not have that behavior:
Private Sub cmdUndo_Click()
If Me.Dirty Then
Me.Undo
Else
Beep
End If
End Sub

Note that an undo button on a form is of limited use. If you are in the
process of entering something invalid, Access won't let you out of the
current control until you fix that. Consequently you can't even get to the
undo button if the current entry is invalid (such as 1/1/ in a date field,
or backspacing all characters out of a required field.)
 
A

Allen Browne

Your rountine will have your button name in place of cmdUndo.

1. Open your form in design view.

2. Right-click your command button, and choose Properties.

3. On the Event tab, set the On Click property to:
[Event Procedure]

4. Click the Build button (...) beside this.
Access opens the code window.
Set up the code as shown.
 
G

Guest

Ok, it seems to be working now. Thank you

Allen Browne said:
Your rountine will have your button name in place of cmdUndo.

1. Open your form in design view.

2. Right-click your command button, and choose Properties.

3. On the Event tab, set the On Click property to:
[Event Procedure]

4. Click the Build button (...) beside this.
Access opens the code window.
Set up the code as shown.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Annemarie said:
Do I substitute cmdUndo_Click() with the name of my button?
 

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

Can't undo? 3
undo changes 2
Command Button Enabled/Disabled 5
get out of control 5
Escape to undo form update 7
Suppress MsgBox 7
Undo Button 2
if duplicate goto record 3

Top