Hi All
I have a audit log setup using the following code and really just need some help working out if this is the best thing for my needs...and if i can speed this up in anyway....:
My main issue is when it gets here in the code - i.e. to update the record with the changes:
My BE is SharePoint 2010 lists...the update for one simple change in Access (using Access BE) takes a split second, but when the BE is SharePoint - it takes about 10-15 seconds (too long in my opinion) - is there something i can do to speed this up?
I also have a question about this line of code:
- it seems it is opening up ALL records in the table - if so why - should it not simply be up adding one new row to the table?
Thanks in advance
I have a audit log setup using the following code and really just need some help working out if this is the best thing for my needs...and if i can speed this up in anyway....:
Code:
Sub AuditChanges(IDField As String, UserAction As String)
On Error GoTo AuditChanges_Err
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim ctl As Control
Dim datTimeCheck As Date
Dim strUserID As String
Set cnn = CurrentProject.Connection
Set rst = New ADODB.Recordset
rst.Open "SELECT * FROM tblAuditTrail", cnn, adOpenDynamic, adLockOptimistic
datTimeCheck = Now()
strUserID = Environ("USERNAME")
MainFormFocus:
Select Case UserAction
Case "EDIT"
For Each ctl In MainForm.Controls 'Screen.ActiveForm.Controls
If ctl.Tag = "Audit" Then
If Nz(ctl.Value) <> Nz(ctl.OldValue) Then
With rst
.AddNew
![DateTime] = datTimeCheck
![UserName] = strUserID
![FormName] = MainForm.Name 'Screen.ActiveForm.Name
![Action] = UserAction
![RecordID] = MainForm.Controls(IDField).Value 'Screen.ActiveForm.Controls(IDField).Value
![FieldName] = ctl.ControlSource
![OldValue] = ctl.OldValue
![NewValue] = ctl.Value
![RiskID] = RiskNum
If ctl.ControlType = 111 Or ctl.ControlType = 110 Then
If ![FieldName] = "RiskTeamWorkstream" Or ![FieldName] = "RiskSubTeam" Or ![FieldName] = "RiskTeamThree" Then
![lookupValNEW] = ctl.Column(2)
Else
![lookupValNEW] = ctl.Column(1)
End If
Else
![lookupValNEW] = ctl.Value
End If
.Update
End With
End If
End If
Next ctl
Case Else
With rst
.AddNew
![DateTime] = datTimeCheck
![UserName] = strUserID
![FormName] = MainForm.Name 'Screen.ActiveForm.Name
![Action] = UserAction
![RecordID] = MainForm.Controls(IDField).Value 'Screen.ActiveForm.Controls(IDField).Value
![RiskID] = RiskNum
.Update
End With
End Select
NextSt:
AuditChanges_Exit:
On Error Resume Next
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
Exit Sub
AuditChanges_Err:
'MsgBox Err.Description, vbCritical, "ERROR!"
Resume AuditChanges_Exit
End Sub
My main issue is when it gets here in the code - i.e. to update the record with the changes:
.Update
My BE is SharePoint 2010 lists...the update for one simple change in Access (using Access BE) takes a split second, but when the BE is SharePoint - it takes about 10-15 seconds (too long in my opinion) - is there something i can do to speed this up?
I also have a question about this line of code:
Code:
rst.Open "SELECT * FROM tblAuditTrail", cnn, adOpenDynamic, adLockOptimistic
Thanks in advance