Programming Help...really stuck..Audit Logs


G

Guest

I am frusterated!

I'm trying to implement Allen Brownes Audit Log code in Access XP and am running into a series of problems. Could i have some help? I would really appreciate it

Problem one

Runtime error 13: Data type mismatc

Code highlighted is

Set db = DBEngine(0)(0

I am not that strong of a VB coder so am not sure about DAO and ADO stuff and how it all works. Here is the full code in this block

Dim db As CurrentProject ' Current databas
Dim sSQL As Strin

'Remove any cancelled update still in the tmp table
Set db = DBEngine(0)(0
sSQL = "DELETE FROM " & sAudTmpTable & ";
db.Execute sSQ

' If this was not a new record, save the old values
If Not bWasNewRecord The
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 ', dbFailOnErro
End I
AuditEditBegin = Tru

Exit_AuditEditBegin
Set db = Nothin
Exit Function
 
Ad

Advertisements

A

Alex Dybenko

should be
Dim db As database

and make sure you have reference to DAO 3.6

--
Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com



Carlee said:
I am frusterated!!

I'm trying to implement Allen Brownes Audit Log code in Access XP and am
running into a series of problems. Could i have some help? I would really
appreciate it.
Problem one:

Runtime error 13: Data type mismatch

Code highlighted is:

Set db = DBEngine(0)(0)

I am not that strong of a VB coder so am not sure about DAO and ADO stuff
and how it all works. Here is the full code in this block:
Dim db As CurrentProject ' Current database
Dim sSQL As String

'Remove any cancelled update still in the tmp table.
Set db = DBEngine(0)(0)
sSQL = "DELETE FROM " & sAudTmpTable & ";"
db.Execute sSQL

' If this was not a new record, save the old values.
If Not bWasNewRecord Then
sSQL = "INSERT INTO " & sAudTmpTable & " ( audType, audDate, audUser ) " & _
"SELECT 'EditFrom' AS Expr1, Now() AS Expr2, NetworkUserName()
AS Expr3, " & sTable & ".* " & _
 
D

Deville

I think where db is dimmed needs to be changed...try this
remove the following 2 lines:

Dim db As CurrentProject ' Current database

and

Set db = DBEngine(0)(0)

then replace with
Dim db As ADODB.Connection
Set db = CurrentProject.Connection
-----Original Message-----
I am frusterated!!

I'm trying to implement Allen Brownes Audit Log code in
Access XP and am running into a series of problems. Could
i have some help? I would really appreciate it.
Problem one:

Runtime error 13: Data type mismatch

Code highlighted is:

Set db = DBEngine(0)(0)

I am not that strong of a VB coder so am not sure about
DAO and ADO stuff and how it all works. Here is the full
code in this block:
Dim db As CurrentProject ' Current database
Dim sSQL As String

'Remove any cancelled update still in the tmp table.
Set db = DBEngine(0)(0)
sSQL = "DELETE FROM " & sAudTmpTable & ";"
db.Execute sSQL

' If this was not a new record, save the old values.
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 & ");"
 
D

Douglas J. Steele

I don't believe there's an object type of CurrentProject, so that won't
work. And converting from DAO to ADO isn't as simple as just changing two
lines of code...
 
Ad

Advertisements

D

david epsom dot com dot au

I'm trying to implement Allen Brownes Audit Log code in Access XP

But that is NOT Allen Browne's code: The bugs are not in his code.
If you have changed the code yourself, it would be courteous as well
as helpful to say so: If you have found the code somewhere else it
would be courteous as well as helpful to say so.

(david)

Carlee said:
I am frusterated!!

I'm trying to implement Allen Brownes Audit Log code in Access XP and am
running into a series of problems. Could i have some help? I would really
appreciate it.
Problem one:

Runtime error 13: Data type mismatch

Code highlighted is:

Set db = DBEngine(0)(0)

I am not that strong of a VB coder so am not sure about DAO and ADO stuff
and how it all works. Here is the full code in this block:
Dim db As CurrentProject ' Current database
Dim sSQL As String

'Remove any cancelled update still in the tmp table.
Set db = DBEngine(0)(0)
sSQL = "DELETE FROM " & sAudTmpTable & ";"
db.Execute sSQL

' If this was not a new record, save the old values.
If Not bWasNewRecord Then
sSQL = "INSERT INTO " & sAudTmpTable & " ( audType, audDate, audUser ) " & _
"SELECT 'EditFrom' AS Expr1, Now() AS Expr2, NetworkUserName()
AS Expr3, " & sTable & ".* " & _
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top