I have an ADP (ADE compiled) project that also requires HIPAA auditing, so I created a function that logs changes into a separate table when fields (text boxes) are changed. It works great, but there are some workstations at one location (on a hospital system's WAN) with extremely slow network access, so they're experiencing a 4-5 second lag when changing values and tabbing from one field to the next. I want to streamline the code, perhaps not having to initiate/open a new recordset every time a field is changed.
the function sits at the top of the form's code:
Function audz(FldVal, FldNm)
Dim cn As ADODB.Connection
Set cn = CurrentProject.Connection
Dim rs_A As ADODB.Recordset
Set rs_A = New ADODB.Recordset
With rs_A
Set .ActiveConnection = cn
.Source = "SELECT * FROM tbl_Audit"
.LockType = adLockOptimistic
.Open
.AddNew
!ActionUser = uzer
!ActionDateTime = Now
!ActionType = "Edit"
!ActionTbl = "tbl_patients"
!PT_ID = PTID 'global
!EditField = FldNm
!EditPreValue = preval 'global
!EditNewValue = FldVal
.Update
End With
End Function
'this is used to hold the previous value
Private Sub City_Dirty(Cancel As Integer)
preval = Me.City
End Sub
'this is used to record the changes
Private Sub City_AfterUpdate()
Call audz(Me.City, "City")
End Sub
Question: Do I have to open the recordset every time or can I open it once (like when the form opens) and then just call the function as needed until form exits?
I'm trying to think of methods to improve efficiency and not have to hit the SQL server so frequently.
thanks,
KPC
the function sits at the top of the form's code:
Function audz(FldVal, FldNm)
Dim cn As ADODB.Connection
Set cn = CurrentProject.Connection
Dim rs_A As ADODB.Recordset
Set rs_A = New ADODB.Recordset
With rs_A
Set .ActiveConnection = cn
.Source = "SELECT * FROM tbl_Audit"
.LockType = adLockOptimistic
.Open
.AddNew
!ActionUser = uzer
!ActionDateTime = Now
!ActionType = "Edit"
!ActionTbl = "tbl_patients"
!PT_ID = PTID 'global
!EditField = FldNm
!EditPreValue = preval 'global
!EditNewValue = FldVal
.Update
End With
End Function
'this is used to hold the previous value
Private Sub City_Dirty(Cancel As Integer)
preval = Me.City
End Sub
'this is used to record the changes
Private Sub City_AfterUpdate()
Call audz(Me.City, "City")
End Sub
Question: Do I have to open the recordset every time or can I open it once (like when the form opens) and then just call the function as needed until form exits?
I'm trying to think of methods to improve efficiency and not have to hit the SQL server so frequently.
thanks,
KPC