Results 1 to 2 of 2
  1. #1
    eliotchs is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2011
    Posts
    24

    Cancel button for adding data

    Hi,

    I have the following in ona cancel button on a form
    it works but i get a blank dialog box after it closes???



    Thanks in Advance

    Joe

    Private Sub Command298_Click()
    On Error GoTo Err_Command298_Click

    DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
    DoCmd.Close

    Exit_Command298_Click:
    Exit Sub
    Err_Command298_Click:
    MsgBox Err.Description
    Resume Exit_Command298_Click

    End Sub

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    First off, get rid of the DoCmd.DoMenuItem code. that is old legacy code that is just around for backwards compatibility.

    Use

    Me.Undo

    or

    DoCmd.RunCommand acCmdUndo

    And the close, you should be explicit so that Access doesn't get confused. If you want to close that form, you can use this code (with no changes to it whatsoever):

    DoCmd.Close acForm, Me.Name, acSaveNo

    (it is important to use acSaveNo so that design changes aren't saved to your form, including filters - and acSaveNo has nothing to do with records)

Please reply to this thread with any new information or opinions.

Similar Threads

  1. BUTTON keeps adding value to TABLE
    By taimysho0 in forum Programming
    Replies: 1
    Last Post: 11-16-2011, 03:03 AM
  2. Select Data Source Won't Cancel!
    By allenrickson in forum Reports
    Replies: 2
    Last Post: 06-21-2011, 11:55 AM
  3. Adding Pop-ups via Command Button
    By jlclark4 in forum Forms
    Replies: 1
    Last Post: 01-05-2011, 02:41 PM
  4. Replies: 4
    Last Post: 04-01-2009, 11:48 AM
  5. Adding Command Button To Form
    By uneek78 in forum Forms
    Replies: 7
    Last Post: 03-27-2009, 07:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums