Saturday, February 25, 2012

dbSeeChanges Problem

I have successfully been using this audit trail process on my .mdb back-end. I have now upsized my back-end to SQL, and low and behold I get an error on the following in my audit module;

The error is 3622, and insists I need to use the "dbSeeChanges" option on the "OpenRecordSet"... I've looked at this till I'm blue in the face - can ANYONE help me out here?
:eek:

Dim DB As DAO.Database
Dim sSQL As String

Set DB = DBEngine(0)(0)

If bWasNewRecord Then
' Copy the new values as "Insert".
sSQL = "INSERT INTO " & sAudTable & " ( audType, audDate, audUser ) " & _
"SELECT 'Insert' AS Expr1, Now() AS Expr2, NetworkUserName() AS Expr3, " & sTable & ".* " & _
"FROM " & sTable & " WHERE (" & sTable & "." & sKeyField & " = " & lngKeyValue & ");"
DB.Execute sSQL, dbFailOnError
Else
' Copy the latest edit from temp table as "EditFrom".
sSQL = "INSERT INTO " & sAudTable & " SELECT TOP 1 " & sAudTmpTable & ".* FROM " & sAudTmpTable & _
" WHERE (" & sAudTmpTable & ".audType = 'EditFrom') ORDER BY " & sAudTmpTable & ".audDate DESC;"
DB.Execute sSQL, dbFailOnError
' Copy the new values as "EditTo"
sSQL = "INSERT INTO " & sAudTable & " ( audType, audDate, audUser ) " & _
"SELECT 'EditTo' AS Expr1, Now() AS Expr2, NetworkUserName() AS Expr3, " & sTable & ".* " & _
"FROM " & sTable & " WHERE (" & sTable & "." & sKeyField & " = " & lngKeyValue & ");"
DB.Execute sSQL, dbFailOnError
' Empty the temp table.
sSQL = "DELETE FROM " & sAudTmpTable & ";"
DB.Execute sSQL, dbFailOnError
End If
AuditEditEnd = TrueTry:

DB.Execute sSQL, dbSeeChanges|||I did that, and it worked great..... but don;t I need dbFailOnError as another option as well? How do I show multiple options??

No comments:

Post a Comment