25/01/2009, 20:36
Bu uygulama ile tabloya kaydedilen verilerde yapılan değişiklikleri, silinen kayıtları veya eklenen yeni kayıtları bu değişiklikleri kimin yaptığını takip edebilirsiniz.
Tüm değişiklikleri tabloya kaydeder.
allenbrowne.com/AppAuditCode.html sayfasındaki kodlardan alıntıdır.
Örnek 64 bit ofiste çalışacak şekilde yeniden düzenlendi.
Tüm değişiklikleri tabloya kaydeder.
allenbrowne.com/AppAuditCode.html sayfasındaki kodlardan alıntıdır.
Function AuditDelBegin(sCAW As String, saudTmpCAW As String, sKeyField As String, lngKeyValue As Long) As Boolean
'On Error GoTo Err_AuditDelBegin
Dim db As DAO.Database
Dim sSQL As String
Set db = DBEngine(0)(0)
sSQL = "INSERT INTO " & saudTmpCAW & " ( degisiklikturu, degistirmetarihi, degistiren ) " & _
"SELECT 'SilinenKayıt' AS Expr1, Now() AS Expr2, NetworkUserName() AS Expr3, " & sCAW & ".* " & _
"FROM " & sCAW & " WHERE (" & sCAW & "." & sKeyField & " = " & lngKeyValue & ");"
db.Execute sSQL, dbFailOnError
Exit_AuditDelBegin:
Set db = Nothing
Exit Function
End Function
Function AuditDelEnd(saudTmpCAW As String, sAudCAW As String, Status As Integer) As Boolean
'On Error GoTo Err_AuditDelEnd
Dim db As DAO.Database
Dim sSQL As String
Set db = DBEngine(0)(0)
If Status = acDeleteOK Then
sSQL = "INSERT INTO " & sAudCAW & " SELECT " & saudTmpCAW & ".* FROM " & saudTmpCAW & _
" WHERE (" & saudTmpCAW & ".degisiklikturu = 'SilinenKayıt');"
db.Execute sSQL, dbFailOnError
End If
'Remove the temp record(s).
sSQL = "DELETE FROM " & saudTmpCAW & ";"
db.Execute sSQL, dbFailOnError
AuditDelEnd = True
Exit_AuditDelEnd:
Set db = Nothing
Exit Function
End Function
Function AuditEditBegin(sCAW As String, saudTmpCAW As String, sKeyField As String, _
lngKeyValue As Long, bWasNewRecord As Boolean) As Boolean
'On Error GoTo Err_AuditEditBegin
Dim db As DAO.Database
Dim sSQL As String
Set db = DBEngine(0)(0)
sSQL = "DELETE FROM " & saudTmpCAW & ";"
db.Execute sSQL
If Not bWasNewRecord Then
sSQL = "INSERT INTO " & saudTmpCAW & " ( degisiklikturu, degistirmetarihi, degistiren ) " & _
"SELECT 'YeniVeri' AS Expr1, Now() AS Expr2, NetworkUserName() AS Expr3, " & sCAW & ".* " & _
"FROM " & sCAW & " WHERE (" & sCAW & "." & sKeyField & " = " & lngKeyValue & ");"
db.Execute sSQL, dbFailOnError
End If
AuditEditBegin = True
Exit_AuditEditBegin:
Set db = Nothing
Exit Function
End Function
Function AuditEditEnd(sCAW As String, saudTmpCAW As String, sAudCAW As String, _
sKeyField As String, lngKeyValue As Long, bWasNewRecord As Boolean) As Boolean
Dim db As DAO.Database
Dim sSQL As String
Set db = DBEngine(0)(0)
If bWasNewRecord Then
sSQL = "INSERT INTO " & sAudCAW & " ( degisiklikturu, degistirmetarihi, degistiren ) " & _
"SELECT 'YeniKayıt' AS Expr1, Now() AS Expr2, NetworkUserName() AS Expr3, " & sCAW & ".* " & _
"FROM " & sCAW & " WHERE (" & sCAW & "." & sKeyField & " = " & lngKeyValue & ");"
db.Execute sSQL, dbFailOnError
Else
sSQL = "INSERT INTO " & sAudCAW & " SELECT TOP 1 " & saudTmpCAW & ".* FROM " & saudTmpCAW & _
" WHERE (" & saudTmpCAW & ".degisiklikturu = 'YeniVeri') ORDER BY " & saudTmpCAW & ".degistirmetarihi DESC;"
db.Execute sSQL
sSQL = "INSERT INTO " & sAudCAW & " ( degisiklikturu, degistirmetarihi, degistiren ) " & _
"SELECT 'EskiVeri' AS Expr1, Now() AS Expr2, NetworkUserName() AS Expr3, " & sCAW & ".* " & _
"FROM " & sCAW & " WHERE (" & sCAW & "." & sKeyField & " = " & lngKeyValue & ");"
db.Execute sSQL
sSQL = "DELETE FROM " & saudTmpCAW & ";"
db.Execute sSQL, dbFailOnError
End If
AuditEditEnd = True
Exit_AuditEditEnd:
Set db = Nothing
Exit Function
End Function
Örnek 64 bit ofiste çalışacak şekilde yeniden düzenlendi.