Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    rpomroy is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Location
    Canada
    Posts
    1

    Audit Trail not working on subform


    Hi CementCarver

    I am currently trying to accomplish this exact scenario. Like most people, I have the code working on the main form but unable to get it to work on the subform. Would you be able to tell me where you placed the code you pasted above? Was this on an event on the actual control? Or is it a module that is called from an event? etc......
    Any help you can provide would be greatly appreciated.

    Thanks

  2. #17
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    Rpomroy

    Send me a private mail, supplying your email address, and I will answer your questions.

    CementCarver

  3. #18
    corvynem is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Nov 2015
    Posts
    2

    SOlution for fontstuff audit trail not working in subforms

    Just registered to post this fix I've used for the audit trail on fontstuff. I figured if I'm still finding this a problem then maybe others are too.

    The problem with subforms is that Screen.ActiveForm doesn't pick up subforms (because the subform itself is a control in its parent form). To get the fontstuff audit code to work in subforms, replace all references to Screen.ActiveForm with Screen.ActiveControl.Parent. This tells Access to read the form name by looking at the parent form of the currently active control.

    Example: Instead of

    Code:
    Screen.ActiveForm.Controls
    use

    Code:
    Screen.ActiveControl.Parent.Controls
    This doesn't work flawlessly in all circumstances - it requires a control on the subform to be selected at the time the audit function is called - but it generally works okay. If you need a more bulletproof method you can create a hidden dummy control on the subform and set the focus to it before calling the procedure.

    Note that deletions are the exception. The fontstuff audit code doesn't record deletions properly anyway - it tries to read the primary key of the deleted record after it's been deleted, which obviously records a wrong value. To get that working you can write the PK to another variable during the Delete event, then pass it to the audit function as an optional parameter when it's called during the DelConfirm event. Also using Screen.ActiveControl.Parent will throw an error if the deleted record was the last record in a recordset (because at that point there is no active control to refer to). Again you can store the form name beforehand using the Delete event if necessary.

  4. #19
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi Corvynem

    thats great, i will adapt for my system

    many thanks

    Steve

  5. #20
    corvynem is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Nov 2015
    Posts
    2
    Hi Steve.

    Glad to be of help. It took me days to figure out but I was so pleased when the audit log recorded its first entry from an edit to a subform!

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

Similar Threads

  1. Replies: 2
    Last Post: 02-09-2013, 12:39 PM
  2. Audit Trail - Pull User Name From Table, Office 2010
    By brharrii in forum Programming
    Replies: 2
    Last Post: 06-05-2012, 03:31 PM
  3. audit trail
    By slimjen in forum Forms
    Replies: 1
    Last Post: 10-13-2011, 01:52 PM
  4. Audit Trail for SubForms Not Working
    By PinkNinja in forum Access
    Replies: 6
    Last Post: 01-07-2011, 11:03 PM
  5. Audit trail not working on form with subform
    By jpkeller55 in forum Access
    Replies: 52
    Last Post: 01-07-2011, 12:39 PM

Tags for this Thread

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