Results 1 to 6 of 6
  1. #1
    jle0003 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    60

    Do not save changes button for form with a subform

    I have a form with a few combo boxes that also contains a subform with several other combo/text boxes. I added a "Cancel" button that should close the form without saving any changes made by the user. The problem is, it only works on the main form objects and not the subform objects. It will undo the changes to the combo boxes on the main form itself, but it will keep the changes made to the combo/text boxes on the subform. Here is the code I have for the button:


    Private Sub cmdCancel_Click()
    On Error GoTo Err_cmdCancel_Click

    Me.Undo
    DoCmd.Close
    Exit_cmdCancel_Click:
    Exit Sub
    Err_cmdCancel_Click:
    MsgBox err.Description
    Resume Exit_cmdCancel_Click
    End Sub


    What else do I add to include the subform? Please help! Thank you!!!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Doubt can be done, at least not without a lot more complicated code and saving 'old' values to a table and retrieving those values to re-edit the records back to the previous values.

    Problem is, a record entry/edit is committed to table when move to another record, close form, or run code. I encountered this issue and gave up. I instead put a label in red letters on form warning users all edits would be saved regardless.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    jle0003 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    60
    I was afraid you would say that. Thanks anyway!

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Oh, I should have mentioned use of unbound forms might be the only alternative. Is the subform in continuous/datasheet or single view?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    jle0003 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    60
    Single view

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Then yes unbound form is option but again, need VBA code to save the new or edited record by using SQL update and insert actions.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 3
    Last Post: 10-08-2012, 08:40 AM
  2. Form Button loses functionality after Save
    By gregu710 in forum Forms
    Replies: 2
    Last Post: 01-17-2012, 05:13 PM
  3. Replies: 1
    Last Post: 07-18-2011, 03:08 AM
  4. Access Form- Save/Close Button error
    By Ashe in forum Forms
    Replies: 3
    Last Post: 02-10-2011, 01:01 PM
  5. VB coding for saving when click on save button in form
    By cwwaicw311 in forum Programming
    Replies: 1
    Last Post: 02-04-2010, 11:11 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