I'm not sure if you are basing your code on the Martin Green (fontstuff) example, but you may find this thread -especially the interaction with PSSMargaret - useful.
As for alternative audit approach, you may find this useful.
If I get a chance, I'll take another look this weekend. Otherwise, it could be hard to find the problem if it doesn't happen all the time and without a pattern.
I'm not sure if you are basing your code on the Martin Green (fontstuff) example, but you may find this thread -especially the interaction with PSSMargaret - useful.
As for alternative audit approach, you may find this useful.
@the DBguy,
the pattern is tht it's deleting the next record in the DB instead of the actual record.
so the null recordid and emplcode for action delete was there is empty record at last.
The problem with DELETE was identified in the dialog with PSSMargaret mentioned previously.
The latest info I have, is the zip file in this post containing a sample database with an audit log and a word document describing the activity and set up I concocted.
I had trouble with ActiveScreen and ActiveControl, so devised an alternate method.
In the dialog with PSSMargaret, we noticed that the wrong record is logged for Deletes.
This database and logging approach was in answer to the issues posed by PSSMargaret. It may not solve the general case and has not been tested in other environments. However, feel free to use it in any development/design as you see fit. If you use it, and/or improve it or extend it, please let the forum know with a post in that original thread.
Good luck with your project.
Please provide a description of how to get into and use your database.
Include any particular Employee or activity(ies) to recreate the issue you are having.
Have you tried setting Show to True and reviewing any messages?
extract and shift click to have access to db.
it's a single form customer with search option
and 3 button add new, save and delete button
previous code was wrking for add and save in audit table but delete was deleting the next record and recording wrong Id.
I've changed it to shared post code
but no actions are being track.
seems I've miss a step
I turned Show to True then using Customer Form, I added and deleted a record.
I had info in immediate window (result of Show), but nothing on the auditTrail. I could see the record changes on the Split form. But I didn't use split form in original so changed Customer to Single form.
Your buttons are using embedded macros --which I do not use.
I tried stepping through the Open event code to check the ctl names and values
Code:
Private Sub Form_Open(Cancel As Integer)
show = True 'for debugging jdraw may 28 19
Dim ctl As Control
On Error Resume Next
For Each ctl In Me.Controls
Debug.Print ctl.Name & " >" & ctl.Value & "<"
Next
End Sub
and got these:
Code:
[COLOR="Blue"]Text214 ><
Combo224 ><
ID >908<
Form Code >1234<
Form Name >AKIKA<
Process ><
User BU ><
Author ><
[/COLOR]
which seem a little strange to me.
I am confused as to what I'm actually looking at as far as the application is concerned.
I did add some records and then deleted 1 and got this in the immediate window (via the Show flag). I was trying to Delete 922.
customer Form_Delete(Cancel As Integer) gRecID is 922
Calling Audit to prepare to DELETE ID =922
Form_AfterDelConfirm(Status As Integer)
Record physically deleted ID 922
922 was deleted from table
Code:
ID EmplCode EmplName Comments HomePhone Address
908 1234 AKIKA
909 A 2345 test
916 987 sam
921 Polly Dactyl "Test of audit, ""audit""" 35 234 235 12 Lakeside Road
923 abear Kodiak Bear jed test2 123Goldilox 1 Dark Forrest Path
924 Bob Robertsville Hi I'm Bob
but nothing in the auditTrail. Still looking.
UPDATE: After supper did some testing and noticed I did get an audittrail record earlier at 4:46???
I am taking another look to see if I can find the source of the 438 and 3265 errors. Because these errors relate to "things" not in a collection, I am suspicious of the control names--just a guess.
I am returning a modified version of your database in zip format. I think I have resolved the 438 and 3265 errors. I have added and modified and deleted records and have successfully recorded the details in tblAuditTrail.
As I said I did change your Navigation form to a Single form, but you can extend/revise as you wish.
Please see the frmComments_JDraw in the database. There are a couple of routines in module ModJ also that I used when debugging.
Good luck with your project. Please keep us updated on your progress.
hi,
ive added a drop-down field "Status" in the form and getting below error wen it adding / saving record. Please advise.
ActiveForm is customer
Label43 Error 438 in form_customer being ignored -6/2/2019 2:44:31 PM
Error 2427 in line 450 (You entered an expression that has no value.) in procedure AuditChanges of Module ModAudit
New Employee: 1234 6/2/2019 2:44:45 PM
ActiveForm is customer
Label43 Error 438 in form_customer being ignored -6/2/2019 2:44:45 PM
Error 2427 in line 450 (You entered an expression that has no value.) in procedure AuditChanges of Module ModAudit
customer Form_Delete(Cancel As Integer) gRecID is 936
Calling Audit to prepare to DELETE ID =936
Label43 Error 438 in form_customer being ignored -6/2/2019 3:11:49 PM
Error 2427 in line 640 (You entered an expression that has no value.) in procedure AuditChanges of Module ModAudit
Form_AfterDelConfirm(Status As Integer)
tmpAuditRec was deleted 6/2/2019 3:11:56 PM
Record physically deleted ID 0
ActiveForm is customer
Label43 Error 438 in form_customer being ignored -6/2/2019 2:44:31 PM
Error 2427 in line 450 (You entered an expression that has no value.) in procedure AuditChanges of Module ModAudit
New Employee: 1234 6/2/2019 3:44:45 PM
ActiveForm is customer
Label43 Error 438 in form_customer being ignored -6/2/2019 2:44:45 PM
Error 2427 in line 450 (You entered an expression that has no value.) in procedure AuditChanges of Module ModAudit
You have "Audit" in the Tag property of Label43. Labels do NOT have values for audit purposes. Label do not have "OldValues" etc.
Remove the Tag value from this Label and all should be OK.
Let me know.