I have a private sub based on an ‘OnDirty’ event. The event creates a record
in an audit log. Here is the code:
Private Sub cmbBusClass_Dirty(Cancel As Integer)
userID = fOSUserName()
FormUsed = Me.Name
ChangeDesc = "Changed Business Class"
RecordNum = Me.RecordID
OrigVal = Me.cmbBusClass
strSQL = "INSERT INTO
tAuditLog(txtNTName,lngRecordID,txtChange,txtForm,dtmDate,dtmTime,txtOrigVal)
" & _
"VALUES ('" & userID & "','" & RecordNum & "','" & ChangeDesc & "','" &
FormUsed & "','" & Date & "','" & Time & "','" & OrigVal & "')"
DoCmd.RunSQL strSQL
End Sub
I want to declare OrigVal as the name of the control, without using the
control name. This type of sub will run on ten different forms, along with
OnError events that will append a 0 if the OrigVal is null.
Is there a way to do this?
Thanks in advance!
PJ
Mr B - 25 Jul 2007 19:58 GMT
Try the following statement:
OrigVal = Me.activecontrol.name
This should capture the name of the currently active contol.

Signature
HTH
Mr B
> I have a private sub based on an ‘OnDirty’ event. The event creates a record
> in an audit log. Here is the code:
[quoted text clipped - 24 lines]
> Thanks in advance!
> PJ
George Nicholson - 25 Jul 2007 20:11 GMT
OrigVal = Screen.ActiveControl.Name
As written, that would store the name of the control in your AuditLog, but I
see no provision to store the value of that control (which would be
Me.Controls(OrigVal).Value or just Screen.ActiveControl.Value)
HTH,
>I have a private sub based on an 'OnDirty' event. The event creates a
>record
[quoted text clipped - 26 lines]
> Thanks in advance!
> PJ