Results 1 to 2 of 2
  1. #1
    aer is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    1

    Help with save prompts in main and sub forms

    Hello,

    I have a main form with a subform and am trying to figure out the best way to have users save data that is entered.
    I know that access automatically saves data entered but I would like to avoid that for instances in which a user enters partial information into a record, and either doesn't finish or makes a mistake and closes out, thinking that that won't save the data. I realize that it is logical to have data from the main form saved as soon as something is put into the subform to prevent parent-child discrepancies, but if a user only enters partial or erroneous data in the main form and nothing in the sub-form I don't want that to be saved.


    What I would like to do is have a prompt that occurs on close of the form that will save the information that's been entered in both the main and subforms. Or prevent saving in both the main and sub forms unless the user actually clicks a "Save" button.


    I have this code in the main form's on close event:

    Code:
     
    
    1. On Error GoTo Close_Error
    2. If Me.Dirty Then
    3. If MsgBox("The record has changed - do you want to save it?", _
    4. vbYesNo + vbQuestion, "Save Changes") = vbNo Then
    5. Me.Undo
    6. End If
    7. End If
    8. Close_Exit:
    9. Exit Sub
    10. Close_Error:
    11. MsgBox Err.Description
    12. Resume Close_Exit
    And similar code in the subform's before update event.
    What's happening now is that even if the user enters partial information only in the main form, the prompt does not occur and the information is saved anyways.

    Could someone please offer any advice on how to clean up these saving issues? I'm no programmer, so any help would be greatly appreciated.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    The main form record is committed as soon as the user changes focus to the subform.

    Could have code in main form BeforeUpdate event that checks if any required fields are not filled in, cancel the update and return user to the main form.

    Can also set fields in table as required and let Access nag the user - no VBA code needed.
    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: 1
    Last Post: 03-05-2013, 01:14 PM
  2. Replies: 11
    Last Post: 11-10-2012, 03:00 AM
  3. Forms Won't save
    By ldare2000 in forum Forms
    Replies: 1
    Last Post: 04-12-2012, 04:10 AM
  4. Stop auto save of forms
    By shanky365 in forum Forms
    Replies: 2
    Last Post: 07-28-2011, 08:37 AM
  5. Replies: 6
    Last Post: 08-05-2010, 04:17 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