I tried manually selecting fields to monitor and now I am getting an error when the SQL executes:
It looks like it is saying only insert ( audType, audDate, audUser ) and then the select statement asks for those 3 values, along with every other piece of info to record. Is this right?
Error="Number of query values and destination fields are not the same."
See my changes with prefix @@@
Code:
Function AuditEditBegin(sTable As String, sAudTmpTable As String, sKeyField As String, _
lngKeyValue As Long, bWasNewRecord As Boolean) As Boolean
Dim db As DAO.Database ' 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 ) " & _
'@@@THIS LINE WAS
'@@@"SELECT 'EditFrom' AS Expr1, Now() AS Expr2, NetworkUserName() AS Expr3, " & sTable & ".*" & _
'Modified to exclude attachments field
"SELECT 'EditFrom' AS Expr1, Now() AS Expr2, NetworkUserName() AS Expr3, " & _
sTable & ".ID, " & _
sTable & ".CompanyID, " & _
sTable & ".EventDate, " & _
sTable & ".EventStartTime, " & _
sTable & ".EventEndTime, " & _
sTable & ".EventType, " & _
sTable & ".ScheduledBy, " & _
sTable & ".Description, " & _
sTable & ".NumAutoQuotes, " & _
sTable & ".NumHomeQuotes, " & _
sTable & ".NumBrochures, " & _
sTable & ".Comments, " & _
sTable & ".WasEmailSent, " & _
sTable & ".WasMeetingSent " & _
"FROM " & sTable & " WHERE (" & sTable & "." & sKeyField & " = " & lngKeyValue & ");"
db.Execute sSQL, dbFailOnError