Re: Allen B - Code to Audit changes

From: Allen Browne (AllenBrowne_at_SeeSig.Invalid)
Date: 10/04/04


Date: Mon, 4 Oct 2004 10:09:37 +0800

Temporarily comment out the error handler at the beginning of each of the
procedures, i.e.:
    ' On Error GoTo Err_Handler
Now you will be able to see which line is failing, which gives you the clue
what to fix.

The most common mistake people make is to either not have the correct fields
in the audit tables, or to no have them in the correct order.

The fact that you get the audit record once only suggests that you have left
a unique index on the audit table, and it is blocking subsequent writes.

-- 
Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"sara" <anonymous@discussions.microsoft.com> wrote in message
news:312c01c4a9af$ef8e2e20$a401280a@phx.gbl...
>I am trying Allen's code from his web site to audit
> changes and I have a few problems.   Dim db As
> DAO.Database didn't compile, so I searched and found that
> I had to go into VBA module, Tools, References and check
> Microsoft DAO 3.6 Object Library.  Maybe I need something
> else too?
>
> But the code isn't working for me to audit changes (I'm
> not auditing Deletes and Inserts)
>
> 1.  I NEVER got the "Edit TO" record.  I get the AutoNum
> in the auditTable (key) as 1,3,5,7 (missing the 2,4,6,8
> which would be the "Edit TO" records.
>
> 2. I got some "Edit From" records, but not consistently. I
> had tried to capture "ChangeDate" with the record (for
> reporting, queries), and was having trouble with that. I
> wanted the form to say "ChangeDate Default Value =Date()"
> but that didn't update the table.  So, I put an Update
> Query in the code when the user presses "Save my Changes"
> to put the Change date in.  (I was told it's better to do
> this in the form, but I can't get that to work).
>
> Now I'm getting ChangeDate all the time in my table, which
> is good.  But I ONLY get the "Edit From" record.  And If I
> Edit the SAME record twice, I don't get the second (or
> third, etc) "Edit From" record.  But when I do edit
> another record, the AutoNum Key in the Audit table is
> incremented by 4 (showing that the table "knew" about the
> others, but didn't write them).
>
> Background:
> I have a main form and subform. The user selects the
> record to edit and clicks "Update record" which brings up
> the "frmUpdateRecord".  When done, the user chooses "Save
> my Changes" button (or Undo or Close without Save).  I
> have the Save Record code with the Click Event of
> the "Update Record" button.  Perhaps this is in conflict
> with the Before Update and After Update events recommended
> in Allen's code?
>
> Thanks - this is one of the last steps for me to show this
> application to our President (a real techno-phobe who
> doesn't believe all this CAN be done!)
>
> Sara