G
gmazza via AccessMonster.com
Hey there,
I have an Audit Trail module that gets called on the Before Update Event in
my Form's code.
I want this module to be used for all forms, so I need the qualifiers correct,
and not use the exact names of the forms. Can anyone help as I keep getting
errors on qualified names. Here is my module:
Dim db As DAO.Database
Dim C As control, xName As String, sSql As String
Dim strComments As String
Dim DatabaseName As String
Dim FormName As String
DoCmd.SetWarnings False
FormName = Screen.ActiveForm.Name
DatabaseName = CurrentProject.Name
For Each C In FormName.Controls ----------------------------------
Error here
strComments = "ElectronicAuthApproved"
If TypeOf C Is TextBox Then
If C.Value <> C.OldValue Or IsNull(C.OldValue) Then
If Not IsNull(C.Value) Then
If FormName.NewRecord = True Then ----------------------
Here it will error next surely
sSql = "INSERT INTO tblaudit ( audType, audDate, audUser,
audForm, audDatabase, FieldName, NewValue, Comments ) " & _
" SELECT 'Insert' AS Expr1 , " & _
"'" & Now & "', " & _
"'" & ap_GetUserName & "', " & _
"'" & "FormName" & "', " & _
"'" & DatabaseName & "', " & _
"'" & C.Name & "', " & _
"'" & C.Value & "', " & _
"'" & strComments & "'"
End If
DoCmd.RunSQL sSql
End If
End If
End If
Next C
DoCmd.SetWarnings True
I have an Audit Trail module that gets called on the Before Update Event in
my Form's code.
I want this module to be used for all forms, so I need the qualifiers correct,
and not use the exact names of the forms. Can anyone help as I keep getting
errors on qualified names. Here is my module:
Dim db As DAO.Database
Dim C As control, xName As String, sSql As String
Dim strComments As String
Dim DatabaseName As String
Dim FormName As String
DoCmd.SetWarnings False
FormName = Screen.ActiveForm.Name
DatabaseName = CurrentProject.Name
For Each C In FormName.Controls ----------------------------------
Error here
strComments = "ElectronicAuthApproved"
If TypeOf C Is TextBox Then
If C.Value <> C.OldValue Or IsNull(C.OldValue) Then
If Not IsNull(C.Value) Then
If FormName.NewRecord = True Then ----------------------
Here it will error next surely
sSql = "INSERT INTO tblaudit ( audType, audDate, audUser,
audForm, audDatabase, FieldName, NewValue, Comments ) " & _
" SELECT 'Insert' AS Expr1 , " & _
"'" & Now & "', " & _
"'" & ap_GetUserName & "', " & _
"'" & "FormName" & "', " & _
"'" & DatabaseName & "', " & _
"'" & C.Name & "', " & _
"'" & C.Value & "', " & _
"'" & strComments & "'"
End If
DoCmd.RunSQL sSql
End If
End If
End If
Next C
DoCmd.SetWarnings True