Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    TenOc is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Feb 2015
    Posts
    94

    Saying form button does not create before update event??

    I have a subroutine that creates an audit trail when changes are made to the data on a form. This subroutine runs when the event “on current” or “before update” occurs. All works well when I move from one record to another record on the form. The problem is when I use a button to save the data on the form (without moving to a different record) or I use a button to close this form and open a different form The subroutine is not executed. I would think since the changed data is saved when either of these buttons is pressed that the on event “before update” would have occurred and the subroutine would have executed.




    What I’m I missing?

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,551
    I *think*, only think that the BeforeUpdate is for bound controls? which would make more sense, as else how does Access know what goes where?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    TenOc is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Feb 2015
    Posts
    94
    I got the save button to work. Simple coding error in my Subroutine.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,551
    Quote Originally Posted by TenOc View Post
    I got the save button to work. Simple coding error in my Subroutine.
    So what about closing the form?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    TenOc is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Feb 2015
    Posts
    94
    Quote Originally Posted by Welshgasman View Post
    So what about closing the form?
    I can not find any typo errors in the click close form event. The subroutine will not run when I click the close form button.

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Can you step back and tell us:
    -why you want an audit trail, and
    -what you want to record?

    I do not understand why you would have a button to invoke an audit trail. I would expect the "audit trail records" to be done automatically when a change(add/modify/delete) occurs. Perhaps you could tell us more.

    You may find this link , and the thread generally, helpful. More info on data macros

    Just curious --why Win 7?
    Last edited by orange; 10-29-2021 at 06:55 AM. Reason: added m$oft link

  7. #7
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    If the record is already saved or more importantly hasn't been edited, then when you press the button there won't be a before update event, as there is NO data update to process.

    I wouldn't run an audit event on the current event, that fires just by moving between records?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  8. #8
    TenOc is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Feb 2015
    Posts
    94
    1. Win 7 because I have not updated my profile since 2007
    2. Office LTS pro plus 2021, but can not select on the drop down selection.

    The user makes a change then while still on the record (it is not saved) he clicks the close form and go to a new form button. This should trigger an audit event, but does not. Closing the from saves the change.

  9. #9
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I suggest you show us some code or a copy of the database with a few records and instructions to "invoke" your audit code.

  10. #10
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    I agree - we need to see your button code and the before update code.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  11. #11
    TenOc is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Feb 2015
    Posts
    94
    Instead of fighting this problem I have chosen to change the "save" button which now works (after I corrected my typo error) to a save-close old form-open new form button. This now works I think the problem is

    When you close a form, the following sequence of events occurs for the form:

    Unload -- Deactivate -- Close

    If there are no active controls on the form, the LostFocus event occurs for the form after the Unload
    event but before the Deactivate event.

    Thus there is NO before change event.

  12. #12
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    There is a Before Update event because the Unload event triggers a save if data has changed.
    You can prove this very easily. In the Forms Before Update event put the following code;

    MsgBox "I'm the before update event firing"

    And see if it is triggered.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  13. #13
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    What is latest status? Do you have something working that you can share with readers OR are things still not working to provide "audit trail"?

  14. #14
    TenOc is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Feb 2015
    Posts
    94
    See 8:34 pasting above. The work around.

  15. #15
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Great. But how does that relate to audit trail?

    An audit trail is a series of records of computer events, about an operating system, an application, or user activities. A computer system may have several audit trails, each devoted to a particular type of activity. Auditing is a review and analysis of management, operational, and technical controls.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Create a button that runs an Update query
    By TrulyVisceral in forum Forms
    Replies: 4
    Last Post: 04-26-2018, 12:25 PM
  2. Replies: 2
    Last Post: 06-14-2016, 03:01 PM
  3. Replies: 7
    Last Post: 05-08-2014, 10:34 AM
  4. Replies: 1
    Last Post: 10-06-2011, 02:28 PM
  5. Replies: 5
    Last Post: 02-08-2011, 11:17 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