Hi,
I need my DB to store history data and have already found what it seems to me as a perfect solution at The code itself is at
I've followed the instructions carefully, but since I'm not a programmer, I got stuck.
My question is: when pasting the code to a new module, what do I need to change? For instance, here's a piece of the code:
Is it OK to adapt all the bolded names to my DB? Because I've done that - but everything went wrong: the form (for which I'm doing this) doesn't show previous entries no more and also it is not possible to enter anything new...
If I change the lngKeyValue in the first line accordingly with the instructions into Me.Sell_ID, the whole first line goes red and a message appears: Compile error, Expected: identifier. If I don't change it, the whole line stays black, but by decompiling I get the message: Compile error: Invalid use of Me keyword...
Please, I really need help on this one...
As always, thanks for any advice!
I need my DB to store history data and have already found what it seems to me as a perfect solution at The code itself is at
I've followed the instructions carefully, but since I'm not a programmer, I got stuck.
My question is: when pasting the code to a new module, what do I need to change? For instance, here's a piece of the code:
Code:
Function AuditDelBegin([b]sTable[/b] As String, [b]sAudTmpTable[/b] As String, [b]sKeyField[/b] As String, [b]lngKeyValue[/b] As Long) As Boolean
'On Error GoTo Err_AuditDelBegin
'Purpose: Write a copy of the record to a tmp audit table.
' Copy to be written to real audit table in AfterDelConfirm.
'Arguments: sTable = name of table to be audited.
' sAudTmpTable = the name of the temp audit table.
' sKeyField = name of AutoNumber field in table.
' lngKeyValue = number in the AutoNumber field.
'Return: True if successful.
'Usage: Call from a form's Delete event. Example:
' Call AuditDelBegin("tblInvoice", "audTmpInvoice", "InvoiceID", Me.InvoiceID)
'Note: Must also call AuditDelEnd in the form's AfterDelConfirm event.
Dim db As DAO.Database ' Current database
Dim sSQL As String ' Append query.
' Append record to the temp audit table.
Set db = DBEngine(0)(0)
sSQL = "INSERT INTO " & [b]sAudTmpTable[/b] & " ( audType, audDate, audUser ) " & _
"SELECT 'Delete' AS Expr1, Now() AS Expr2, NetworkUserName() AS Expr3, " & [b]sTable[/b] & ".* " & _
"FROM " & [b]sTable[/b] & " WHERE (" & [b]sTable[/b] & "." & [b]sKeyField[/b] & " = " & [b]lngKeyValue[/b] & ");"
db.Execute sSQL, dbFailOnError
Exit_AuditDelBegin:
Set db = Nothing
Exit Function
Err_AuditDelBegin:
Call LogError(Err.Number, Err.Description, conMod & ".AuditDelBegin()", , False)
Resume Exit_AuditDelBegin
End Function
Is it OK to adapt all the bolded names to my DB? Because I've done that - but everything went wrong: the form (for which I'm doing this) doesn't show previous entries no more and also it is not possible to enter anything new...
If I change the lngKeyValue in the first line accordingly with the instructions into Me.Sell_ID, the whole first line goes red and a message appears: Compile error, Expected: identifier. If I don't change it, the whole line stays black, but by decompiling I get the message: Compile error: Invalid use of Me keyword...
Please, I really need help on this one...
As always, thanks for any advice!