By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,504 Members | 1,473 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,504 IT Pros & Developers. It's quick & easy.

Audit Log does not work for me

P: 16
I am using Access 2003.
Regarding Allen Browne's audit log, I got copy all the codes and worked step by step according to the instructions, but there was some error occured when I tried to edit the data. The error message was Run-time error '3075': syntax error (missing operator) in query expression '(nameOfTheTableBeingAudited.KeyField = 1)'.
Is this a problem with the keyfield? This autonumber primary key does not seem to increment? Frankly speaking, I dont quite understand how this autonumber primary key work. How can it possibly know whether the new information is indeed a new record, therefore increase the index by one, or the info is just update on the existing record, keeping the same index.
Thank you for any reply in advance...

xiaowei
Jun 5 '07 #1
Share this Question
Share on Google+
5 Replies


Rabbit
Expert Mod 10K+
P: 12,316
I am using Access 2003.
Regarding Allen Browne's audit log, I got copy all the codes and worked step by step according to the instructions, but there was some error occured when I tried to edit the data. The error message was Run-time error '3075': syntax error (missing operator) in query expression '(nameOfTheTableBeingAudited.KeyField = 1)'.
Is this a problem with the keyfield? This autonumber primary key does not seem to increment? Frankly speaking, I dont quite understand how this autonumber primary key work. How can it possibly know whether the new information is indeed a new record, therefore increase the index by one, or the info is just update on the existing record, keeping the same index.
Thank you for any reply in advance...

xiaowei
What is the full line of code that triggers the error? I've never used Allen Browne's audit log but I'll see what I can do.

Simply speaking, it knows if it's a new record or an update depending on which record it is on. Basically, new records are appended to the end of the table. If you are at the end of the table, then you are adding a new record, if you are on any record before that, then you are editing a record. The same goes for a form, except they often only show one record at a time. If you are at the end of the recordset of the form then you are adding a new record, if not, then you are editing a record.
Jun 5 '07 #2

P: 16
What is the full line of code that triggers the error? I've never used Allen Browne's audit log but I'll see what I can do.

Simply speaking, it knows if it's a new record or an update depending on which record it is on. Basically, new records are appended to the end of the table. If you are at the end of the table, then you are adding a new record, if you are on any record before that, then you are editing a record. The same goes for a form, except they often only show one record at a time. If you are at the end of the recordset of the form then you are adding a new record, if not, then you are editing a record.
Hi rabbit, thank you for your reply...
This is the link to Allen Browne's code http://allenbrowne.com/AppAuditCode.html
and when I tried to modify the value of a field for an exiting record, I got this part highlighted:
If Not bWasNewRecord Then
sSQL = "INSERT INTO " & sAudTmpTable & " ( audType, audDate, audUser ) " & _
"SELECT 'EditFrom' AS Expr1, Now() AS Expr2, NetworkUserName() AS Expr3, " & sTable & ".* " & _
"FROM " & sTable & " WHERE (" & sTable & "." & sKeyField & " = " & lngKeyValue & ");"
db.Execute sSQL, dbFailOnError
End If
AuditEditBegin = True

I am totally lost... help!!!

xiaowei
Jun 6 '07 #3

Rabbit
Expert Mod 10K+
P: 12,316
I am using Access 2003.
Regarding Allen Browne's audit log, I got copy all the codes and worked step by step according to the instructions, but there was some error occured when I tried to edit the data. The error message was Run-time error '3075': syntax error (missing operator) in query expression '(nameOfTheTableBeingAudited.KeyField = 1)'.
Is this a problem with the keyfield? This autonumber primary key does not seem to increment? Frankly speaking, I dont quite understand how this autonumber primary key work. How can it possibly know whether the new information is indeed a new record, therefore increase the index by one, or the info is just update on the existing record, keeping the same index.
Thank you for any reply in advance...

xiaowei
How are you calling the function?
Where are you calling the function?
What is the name of your audit log table?
What is the name of the table you're trying to log?
What is the name of the key field in the table you're trying to log?

His code requires you to define these names so it knows where to put everything. At this point, it looks like you're using what he left. I doubt your table is named nameOfTheTableBeingAudited.
Jun 6 '07 #4

P: 16
Thank you rabbit, it is working fine with me now...
allen browne's instruction is very comprehensive and idiot-proof...
though I didnt really understand how it works when I just started over, I just followed, and I got all the tables named properly and functions been called correctly... so I was really confused why I kept getting this error message. I finally discovered that after putting "[ ]" around all the table names in the declaration of sql variables, it functioned just like the way as described. Not familiar with the syntax at all, so I dont know which should be the correct way... anyway it works now... I am so glad.. Thank you!!

Xiaowei
Jun 7 '07 #5

Rabbit
Expert Mod 10K+
P: 12,316
Glad you got it working, good luck.
Jun 7 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.