Results 1 to 3 of 3
  1. #1
    sleake is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    51

    Error running A Browne's audit trail - Audit working in another table in the database

    I've used Allen Browne's audit code on several databases, and even on another form in the database I'm working on. The audit on that form works perfectly.

    On a new form, I've inserted all the code in the OnDelete, AfterDelConfirm, BeforeUpdate and AfterUpdate events. When I test it using the form, I get a ByRef argument type mismatch in the BeforeUpdate event, highighting the bWasNewRecord item. As you see, I have other code to record the user name and edit date as well. I tried importing the entire database into a fresh one, but the error still appeared. I compared my new audit table with the one that is working and saw that the working table had the audID autonumber primary key at the bottom of the field list, so I moved that field in the new table. Still a ByRef aurgument mismatch. I'm not sure what to do next. Sure would appreciate some guidance.

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    'Enters a user name in the EditedBy field
    Me.[txtEditedBy] = CurrentUser()


    'Inserts a timestamp for last edit whenever the record is modified
    Me.[dtEditedDate] = Now()

    bWasNewRecord = Me.NewRecord
    Call AuditEditBegin("tbl_SFTP_Partners", "tbl_AudTemp_SFTP_Partners", "PartnerID", Nz(Me.PartnerID, 0), bWasNewRecord)

    End Sub

  2. #2
    alcapps is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    292
    usually this means there may be a missing reference.
    go to a module and select tools, references and check if any of them say missing..
    the only other thing you can do is to post the form with some data so we can debug the form.

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    It sounds to me like you missed step 1 at "Enter the Form Events" (See bottom of page at http://allenbrowne.com/AppAudit.html)

    The top of the form code page should have:
    Code:
    Option Compare Database  'you should always have these two lines at the top of every code page
    Option Explicit
    Dim bWasNewRecord As Boolean  '<<must be here
    
    
    Private Sub Form_BeforeUpdate(Cancel As Integer)
      'Enters a user name in the EditedBy field
      Me.[txtEditedBy] = CurrentUser()
    
      'Inserts a timestamp for last edit whenever the record is modified
      Me.[dtEditedDate] = Now()
    
      bWasNewRecord = Me.NewRecord
      Call AuditEditBegin("tbl_SFTP_Partners", "tbl_AudTemp_SFTP_Partners", "PartnerID", Nz(Me.PartnerID, 0), bWasNewRecord)
    
    End Sub 
    
    'other code
    Do you have the line in RED??

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

Similar Threads

  1. Audit Trail - Pull User Name From Table, Office 2010
    By brharrii in forum Programming
    Replies: 2
    Last Post: 06-05-2012, 03:31 PM
  2. Audit Trail
    By bigroo in forum Programming
    Replies: 4
    Last Post: 02-22-2012, 07:55 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