Array or not to Array?
Thanks in Advance!
I want to create a module to process data on different forms. I’m thinking about making an array when a form is opened of the beginning data. Then if a specific button is pressed, create another array of form data and compare the two. Noting the changes between the first and second. Placing this information in a table for later use. Multiple changes can be made on the first form so a separate entry in the table would be made.
Currently I am using the before_update, and run a mod called auditchange. This works using the oldvalue and the newvalue. what I would like to do is do this on a form basis instead of each object. Taking a picture prior to adding or changing data on the form then comparing that to the finished form (if I choose).
Also I would like to write a module to do the array building so I do not have to do it for each form.
One last thing, I am using Access 97.
Please any thoughts or suggestions on this are welcomed.
Current:
In the form:
Private Sub PayFrequencyCode_BeforeUpdate(Cancel As Integer)
auditchange
End Sub
Private Sub PlanID_BeforeUpdate(Cancel As Integer)
auditchange
End Sub
Private Sub ReviewScore_BeforeUpdate(Cancel As Integer)
auditchange
End Sub
Private Sub auditchange()
On Error GoTo err_AuditChange
If IsNull(Me.ActiveControl) Then
' skip
Else
Set ctlCC = Me.ActiveControl
CGLOG txtTableName, publink, ctlCC, txtFormname, txtName
End If
exit_auditchange:
Exit Sub
err_AuditChange:
GoTo exit_auditchange
End Sub
**************** Module
sub CGLOG(txtTableName As String, publink As Long, pubCTL As Control, txtFormname As String, txtName As String)
Dim txt_new As String
Dim txt_old As String
Dim txt_Field As String
txt_Field = pubCTL.NAME
If IsNull(pubCTL.OldValue) Then
txt_old = "None"
Else
txt_old = pubCTL.OldValue
End If
If IsNull(pubCTL.Value) Then
txt_new = "None"
Else
txt_new = pubCTL.Value
End If
WAU txtTableName, publink, txt_Field, txt_old, txt_new, txtFormname, txtName
End Sub
Sub WAU(txtTableName, lngRecordNum, txtFieldName, OrgValue, CurValue, txtFormname, txtName)
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("AuditTable")
rs.addnew
rs!TableName = UCase(txtTableName)
rs!RecordPrimaryKey = lngRecordNum
rs!FieldName = txtFieldName
rs!LoginName = (Forms![Global]![LoginName])
rs!MachineName = Forms![Global]![txt_G_MachineName]
rs!User = (Forms![Global]![txt_G_CurrentUser])
rs!FormName = UCase(txtFormname)
If IsNull(OrgValue) Or OrgValue = "" Then
OrgValue = " "
End If
rs!OriginalValue = OrgValue
rs!NewValue = CurValue
rs!EmpName = txtName
rs!dateAdded = Now()
rs.Update
rs.Close
db.Close
End Sub
Thank you Jim.
Thanks in Advance!
I want to create a module to process data on different forms. I’m thinking about making an array when a form is opened of the beginning data. Then if a specific button is pressed, create another array of form data and compare the two. Noting the changes between the first and second. Placing this information in a table for later use. Multiple changes can be made on the first form so a separate entry in the table would be made.
Currently I am using the before_update, and run a mod called auditchange. This works using the oldvalue and the newvalue. what I would like to do is do this on a form basis instead of each object. Taking a picture prior to adding or changing data on the form then comparing that to the finished form (if I choose).
Also I would like to write a module to do the array building so I do not have to do it for each form.
One last thing, I am using Access 97.
Please any thoughts or suggestions on this are welcomed.
Current:
In the form:
Private Sub PayFrequencyCode_BeforeUpdate(Cancel As Integer)
auditchange
End Sub
Private Sub PlanID_BeforeUpdate(Cancel As Integer)
auditchange
End Sub
Private Sub ReviewScore_BeforeUpdate(Cancel As Integer)
auditchange
End Sub
Private Sub auditchange()
On Error GoTo err_AuditChange
If IsNull(Me.ActiveControl) Then
' skip
Else
Set ctlCC = Me.ActiveControl
CGLOG txtTableName, publink, ctlCC, txtFormname, txtName
End If
exit_auditchange:
Exit Sub
err_AuditChange:
GoTo exit_auditchange
End Sub
**************** Module
sub CGLOG(txtTableName As String, publink As Long, pubCTL As Control, txtFormname As String, txtName As String)
Dim txt_new As String
Dim txt_old As String
Dim txt_Field As String
txt_Field = pubCTL.NAME
If IsNull(pubCTL.OldValue) Then
txt_old = "None"
Else
txt_old = pubCTL.OldValue
End If
If IsNull(pubCTL.Value) Then
txt_new = "None"
Else
txt_new = pubCTL.Value
End If
WAU txtTableName, publink, txt_Field, txt_old, txt_new, txtFormname, txtName
End Sub
Sub WAU(txtTableName, lngRecordNum, txtFieldName, OrgValue, CurValue, txtFormname, txtName)
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("AuditTable")
rs.addnew
rs!TableName = UCase(txtTableName)
rs!RecordPrimaryKey = lngRecordNum
rs!FieldName = txtFieldName
rs!LoginName = (Forms![Global]![LoginName])
rs!MachineName = Forms![Global]![txt_G_MachineName]
rs!User = (Forms![Global]![txt_G_CurrentUser])
rs!FormName = UCase(txtFormname)
If IsNull(OrgValue) Or OrgValue = "" Then
OrgValue = " "
End If
rs!OriginalValue = OrgValue
rs!NewValue = CurValue
rs!EmpName = txtName
rs!dateAdded = Now()
rs.Update
rs.Close
db.Close
End Sub
Thank you Jim.