Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UNDO not working properly. It does when using breakpoint and stepping

Status
Not open for further replies.
Jan 22, 2001
124
US
This problem is VERY puzzling to me and it's the only thing holding up the release of this dbase. I have a form that allows users to make changes to a record. I don't want these changes to be permanent unless the user clicks a button which changes a flag (to a "1") on the form. This flag is then evaluated on the forms close event:

Private Sub Form_Close()
On Error GoTo Err_Form_Close_Click

If Me![Undo] = 0 Then
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
Else
End If
Exit Sub

Err_Form_Close_Click:
End Sub

Well, this seems to work just fine when I put a breakpoint in the code at the "If" statement, and step thorough the code. When I remove the breakpoint and just run normally, the Undo does not work. This is driving me crazy!

Any help would be GREATLY appreciated. Thanks in advance.

--Rob
 
Undo is a reserved word. It might be the source of your problem. Try changing the field name (i.e. Me![Undo] to Me![txtUndo])
 
This looks like a timing problem - try adding

Code:
DoEvents

after the
Code:
DoCmd.DoMenuItem
line.

If this doesn't sort it, move your Undo code into the form's OnUnload event instead, which should fire before the form's OnClose event. [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top