Report Offensive Message

RE: A simple solution for tracking changes to Access data
Hello, I used this successfully on forms where the data is only based on a table. However when the data comes from a query when the code evaluates a field that comes from a related table you get error 3251.

Check out http://kbalertz.com/207836/Error-OldValue-Property.aspx for detail on this issue

The solution to this is that you must setup a clone record set in the OnCurrent operation of the form and then draw the old values from this record set.

That works when you type in the field actual name such as rs![OrderName] but the problem is that this code is made so you don't have to type in each control on each form.

Therefore I want to dynamically set the field name in the rs!FIELDNAME. How is this done I have tried rs!(ctl), I have tried concantenating a string and using that variable FIELDNAME="["&ctl&"]" I have even tried FIELDNAME="rs!["&ctl&"]" nothing seems to work. It must be possible.

here is the current code I have

This is in the AuditTrail code of the form itself:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
For Each ctl In frm.Controls


With ctl
'Avoid labels and other controls with Value property.
ControlName = ctl.Name

If (.ControlType = acTextBox) Or (.ControlType = acComboBox) Or (.ControlType = acOptionGroup) Or (.ControlType = acCheckBox) Or (.ControlType = acMemo) Then 'Or acListBox Then
If .Enabled = True Then
varBefore = rs!(ControlName) ' rs![InstallationPosition] works so the record set seems OK
If .Value
Posted by BoWhite
1st Sep 2010