Hello everyone. Here is my current situation:
I am working with a database that I set up with an Audit trail as described in this blog post. It includes rich text fields so I am using the VBA function method described in the comment section. I have two fields that I am auditing called "DCDocuments" and "ClinicalUpdates"
I recently broken out a piece of information from the ClinicalUpdates field into a combo box "cboRloC", but I still need that information included in the ClinicalUpdates audit trail if changes are made to it. I grab the information from the combo box, concatenate it to rest of the data in the appropriate field, and feed that new variable it into the AuditTrail function using the following code:
The issue I am running into is that this code is placed in the BeforeUpdate property of the ClinicalUpdates textbox and so it will only fire if a change is made to that textbox on the form. I also want to be able to execute the same code if a user changes the value of the combo box without also making a change to the ClinicalUpdates textbox.
At first I tried use the above code on the BeforeUpdate property of the combo box with the following change to the function call:
This made the entry in the table that I needed, but it did so as soon as the value of the Combo Box was changed. I only want an audit entry made if the value in combo box is changed on the form and that change is saved to the database.
How can I accomplish this?
I am working with a database that I set up with an Audit trail as described in this blog post. It includes rich text fields so I am using the VBA function method described in the comment section. I have two fields that I am auditing called "DCDocuments" and "ClinicalUpdates"
I recently broken out a piece of information from the ClinicalUpdates field into a combo box "cboRloC", but I still need that information included in the ClinicalUpdates audit trail if changes are made to it. I grab the information from the combo box, concatenate it to rest of the data in the appropriate field, and feed that new variable it into the AuditTrail function using the following code:
VBA Code:
Dim varNewMix As Variant
Dim strRLoC As String
strRLoC = Me.cboRLoC.Column(1)
varNewMix = "<div><strong>Recommended level of care:</strong> " & strRLoC & "</div>" & Screen.ActiveControl
Call AuditTrail(Screen.ActiveForm.RecordSource, Screen.ActiveControl.ControlSource, Me.[CASE #], Screen.ActiveControl.OldValue, varNewMix)
The issue I am running into is that this code is placed in the BeforeUpdate property of the ClinicalUpdates textbox and so it will only fire if a change is made to that textbox on the form. I also want to be able to execute the same code if a user changes the value of the combo box without also making a change to the ClinicalUpdates textbox.
At first I tried use the above code on the BeforeUpdate property of the combo box with the following change to the function call:
VBA Code:
Call AuditTrail(Screen.ActiveForm.RecordSource, "ClinicalUpdates", Me.[CASE #], Me.ClinicalUpdates.Value, varNewMix)
This made the entry in the table that I needed, but it did so as soon as the value of the Combo Box was changed. I only want an audit entry made if the value in combo box is changed on the form and that change is saved to the database.
How can I accomplish this?