Results 1 to 12 of 12
  1. #1
    Join Date
    Mar 2004
    Posts
    660

    Unanswered: i don't want to save record on close button

    Is that anyway we can not save the record when click the close button. Do we have cancel button that won't save any change? Thanks again!

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    If memory serves correctly
    Code:
    DoCmd.RunCommand acCmdUndo
    George
    Home | Blog

  3. #3
    Join Date
    Mar 2004
    Posts
    660
    Let me explain my situation. In my edit form i have two unbound text fields and one bound checkbox field. The two unbound text fields will be append to field in the database when click save button. The thing when user uses close button, all the unbound text fields won't be save it. But the checkbox field will be save. If use DoCmd.RunCommand acCmdUndo, and use didn't change anything for check box, it will show up a message, unod is not available.

    Thanks.

  4. #4
    Join Date
    Jul 2006
    Posts
    108
    Code:
    docmd.Close,,acSaveNo

  5. #5
    Join Date
    May 2005
    Posts
    1,191
    Why not include the check box in the append query on Save?
    Me.Geek = True

  6. #6
    Join Date
    Mar 2004
    Posts
    660
    Thanks. This is great idea. I am going to append the check box and create cancel button to unsave. The questsion is when append the check box, it shows the value is 0 or 1, how to change it to "Yes" or "No".

    Thanks all.
    Last edited by yyu; 08-07-07 at 09:31.

  7. #7
    Join Date
    Mar 2004
    Posts
    660
    Sorry, the code for close button that doesn't want to save record didn't work. It still save it.

    docmd.Close,,acSaveNo

  8. #8
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    441
    Yes, the save arguement of the DoCmd.Close method, is only for design changes.

    Now, if you're concerned about unsaved changes, you could do

    If Me.Dirty Then Me.Undo

    What might create a bit of challenge, is what happens if the record is already saved? Now, that would depend a little on your setup.
    Roy-Vidar

  9. #9
    Join Date
    May 2005
    Posts
    1,191
    The way I've always done this (and I thought this to be really the only way, with slight variations out there), is to have as many unbound text boxes and check boxes as you need. Then you copy the info into the controls from a rs. That way the users are working with "dummy" info, it doesn't matter what they do to them.

    Then you have a Save button similar to the one you have; only this button on the On Click event will load whatever is in the controls back into the table. If the user chooses to close early without clicking the save button, it won't affect any of the data in the table, they'll just loose they're dummy data (I usually msgbox the user at this point to make sure they don't need to save the data).

    EDIT: Typo
    Last edited by nckdryr; 08-07-07 at 15:34.
    Me.Geek = True

  10. #10
    Join Date
    Mar 2004
    Posts
    660
    Yes, that is great idea. But i think Access should have this function in the future.

  11. #11
    Join Date
    May 2005
    Posts
    1,191
    There's lots of things we wish Access could do. But if Access could do them all, you'd have one big and confusing software package and we'd be out of a job
    Me.Geek = True

  12. #12
    Join Date
    Mar 2004
    Posts
    660
    You are absolutely right. Hope they always have weakness so that we can keep our jobs.No complain anymore.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •