Results 1 to 2 of 2
  1. #1
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727

    VBA in Before Update Event

    Had this code to a Before Update Event. How do I get something like this to work on a On Click Button Event?



    Private Sub Form_BeforeUpdate(Cancel As Integer)

    'Provide the user with the option to save/undo
    'changes made to the record in the form

    If MsgBox("Changes have been made to this record." _
    & vbCrLf & vbCrLf & "Do you want to save these changes?" _
    , vbYesNo, "Changes Made...") = vbYes Then
    DoCmd.Save
    Else
    DoCmd.RunCommand acCmdUndo
    End If
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Did you try that code in the button Click event?

    The BeforeUpdate event should not have DoCmd.Save because that is command to save the form, not save data; also, the record save should have already been initiated.

    The BeforeUpdate event should have Cancel = True in the Else.
    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. After Update event help
    By noaccessguru in forum Forms
    Replies: 9
    Last Post: 08-08-2013, 12:36 AM
  2. Before Update Event Help
    By bklewis in forum Access
    Replies: 8
    Last Post: 03-25-2012, 03:58 PM
  3. Before Update Event
    By randolphoralph in forum Programming
    Replies: 0
    Last Post: 06-15-2010, 09:26 AM
  4. Determining cause of Update event
    By RJosephNewton in forum Access
    Replies: 3
    Last Post: 03-25-2010, 04:34 PM
  5. Syntax For After Update Event
    By MuskokaMad in forum Forms
    Replies: 14
    Last Post: 03-12-2010, 01:48 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