Results 1 to 6 of 6
  1. #1
    selvakumar.arc is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Posts
    49

    Closing the form without saving the information


    I am trying to close the form without saving form input, following are the code snippet. But it is not working means that the form input are saving in database even if the user click the exit button. I dont know what is the issue here...
    Private Sub cmdExit_Click()
    DoCmd.Close acForm, Me.Name, acSaveNo
    End Sub

    Regards,
    Selvakumar R

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    DoCmd.Close acForm, Me.Name, acSaveNo

    The "acSaveNo" parameter doesn't affect the data, it is if you have made changes to the form (using code). For example, if you have code to add an unbound text box and you didn't want to save the change, then you would use "acSaveNo".

    Data is automatically saved if you change records or close the form. There are a couple of other ways the data is saved - on a requery (I think).


    I have used the "Me.Undo" command in button click events.... with varying amounts of success.

  3. #3
    selvakumar.arc is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Posts
    49
    Yes, I added "Me.Undo" before closing the form and it is working. Thanks for your support.

  4. #4
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    ssanfu - Should he check "If Me.Dirty" before executing the Me.Undo? I can't recall one way or the other, but I'm wondering if there might be a gotcha where something that had been officially "saved" might get undone.

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    @Dal - Good point. I don't recall what code I ended up with. Hence the "with varying amounts of success".

    When I find time I will have to experiment .... err I mean do some testing.....

  6. #6
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    You should Experiment... FOR SCIENCE! Mwaaahhaaahhaaa!

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

Similar Threads

  1. Closing access database without saving
    By onaggar in forum Access
    Replies: 7
    Last Post: 12-19-2013, 06:23 PM
  2. Saving look up information
    By keiath in forum Forms
    Replies: 9
    Last Post: 10-08-2013, 12:57 PM
  3. Form Combo Box Saving Wrong Information
    By Steve62 in forum Reports
    Replies: 5
    Last Post: 11-12-2012, 02:29 PM
  4. Closing a form through VBA
    By ghostmachine in forum Forms
    Replies: 4
    Last Post: 12-13-2010, 01:57 PM
  5. Closing and saving a form
    By Lxmanager in forum Forms
    Replies: 14
    Last Post: 11-21-2010, 02:04 AM

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