Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / July 2007

Tip: Looking for answers? Try searching our database.

Reference a control dynamically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PJFry - 25 Jul 2007 19:26 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.