asked on
'In the on click command on the button
Dim x As Integer
If Not IsNull(Me.ReportID) Then
x = WriteAudit(Me, Me.ReportID)
End If
'In the module which I have left as Module1
Public Function WriteAudit(frm As Form, lngID As Long) As Boolean
On Error GoTo err_WriteAudit
Dim ctlC As Control
Dim strSQL As String
Dim bOK As Boolean
bOK = False
DoCmd.SetWarnings False
' For each control.
For Each ctlC In frm.Controls
If TypeOf ctlC Is TextBox Or TypeOf ctlC Is ComboBox Then
If ctlC.Value <> ctlC.OldValue Or IsNull(ctlC.OldValue) Then
If Not IsNull(ctlC.Value) Then
strSQL = "INSERT INTO tAudit ( ReportID, FieldName, AudB4, AudAft, User, [Date]) " & _
" SELECT " & lngID & " , " & _
"'" & ctlC.Name & "', " & _
"'" & ctlC.OldValue & "', " & _
"'" & ctlC.Value & "', " & _
"'" & GetAnalyst & "', " & _
"'" & Now & "'"
'Debug.Print strSQL
DoCmd.RunSQL strSQL
End If
End If
End If
Next ctlC
WriteAudit = bOK
exit_WriteAudit:
DoCmd.SetWarnings True
Exit Function
err_WriteAudit:
MsgBox Err.Description
Resume exit_WriteAudit
End Function
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.
TRUSTED BY
Otherwise we need to know which line causes the error.