Kayıt ve Veri Değişikliklerini İzleme Uygulaması

1 2 3
25/01/2009, 20:36

ozanakkaya

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.



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.
25/01/2009, 20:46

C*e*l*o*y*c*e

Teşekkürler, Eline sağlık.
25/01/2009, 20:56

access_delisi

Hocam ellerinize sağlık
25/01/2009, 21:53

ercansahin

İnceledim, çok kullanışlı ve faydalı bir çalışma olmuş
25/01/2009, 22:02

derebeyi

Hocam ellerinize sağlık çookk güzel olmuş
25/01/2009, 22:18

realperest

Kayıt değişikliklerini yapan makina adı yerine kullanıcı girişi yapanın ismi olsa daha güzel olur.
1 2 3