G
gmazza via AccessMonster.com
Hey there,
I have a loop that goes through each textbox on the form and inserts a record
for each one that changed into an Audit table. There are a couple text boxes
I don't want inserted, I don't care that they changed, is there anyway I can
exclude them?
Here is a snipet of my code:
For Each C In Forms(FormName).Controls
If TypeOf C Is TextBox Then
If C.Value <> C.OldValue Or IsNull(C.OldValue) Then
If Not IsNull(C.Value) Then
If Forms(FormName).NewRecord = True Then
strAudType = "Insert"
Else
strAudType = "Update"
End If
sSql = "INSERT INTO Audit ( audType, audDate, audUser,
audForm, audDatabase, FieldName, NewValue, Comments ) " & _
"VALUES(" & _
"'" & strAudType & "', " & _
"'" & TimeAndDate() & "', " & _
"'" & ap_GetUserName & "', " & _
"'" & FormName & "', " & _
"'" & DatabaseName & "', " & _
"'" & C.Name & "', " & _
"'" & C.Value & "', " & _
"'" & strComments & "' " & _
")"
CurrentDb.Execute sSql, dbFailOnError
End If
End If
End If
Next C
I have a loop that goes through each textbox on the form and inserts a record
for each one that changed into an Audit table. There are a couple text boxes
I don't want inserted, I don't care that they changed, is there anyway I can
exclude them?
Here is a snipet of my code:
For Each C In Forms(FormName).Controls
If TypeOf C Is TextBox Then
If C.Value <> C.OldValue Or IsNull(C.OldValue) Then
If Not IsNull(C.Value) Then
If Forms(FormName).NewRecord = True Then
strAudType = "Insert"
Else
strAudType = "Update"
End If
sSql = "INSERT INTO Audit ( audType, audDate, audUser,
audForm, audDatabase, FieldName, NewValue, Comments ) " & _
"VALUES(" & _
"'" & strAudType & "', " & _
"'" & TimeAndDate() & "', " & _
"'" & ap_GetUserName & "', " & _
"'" & FormName & "', " & _
"'" & DatabaseName & "', " & _
"'" & C.Name & "', " & _
"'" & C.Value & "', " & _
"'" & strComments & "' " & _
")"
CurrentDb.Execute sSql, dbFailOnError
End If
End If
End If
Next C