You can use a form's ActiveControl property to identify the current
control.
But if you wish to call a procedure from any form you'd also need to
include
an argument to accept the form's name if you use one which accepts the
name
of the control, both declared as String. Then you can them pass them like
so:
Dim ctrl as Control
Dim strFormName as String
Dim strControlName As String
Set ctrl = Me.ActiveControl
strControlName = ctrl.Name
strFormName = Me.Name
MyProcedure strFormName, strControlName
in which case the procedure would be declared like this:
Sub MyProcedure (strFormName As String, strControlName As String)
and the code in the procedure would be something like:
Forms(strFormName).Controls(strControlName).Tag = "Foo"
or the procedure's argument could be declared as Control:
Sub MyProcedure (ctrl As Control)
and you can pass a reference to the control to it:
MyProcedure ctrl
and the code in the procedure would be something like:
ctrl.Tag = "Bar"
The names of the variables passed into the procedure don't have to be the
same as the names of the arguments.
Ken Sheridan
Stafford, England
Apparently my comm is bad. Let me put like this. In a module one can
change
an objects property with this syntax,
Forms![FlatFileData].[lblSort].Caption = “Caption hereâ€
The form name is “FlatFileDataâ€
The label is name “lblSortâ€
Hopefully no arguments with that.
OK, now what I want to do is pass the object (in this case lblSort) to
that
line of code. I assuming that it can’t be done and I found another way to
accomplish the same thing.
Let me break this down further. As an on click event on any object, I want
to call this line of code passing that objects name. In doing this I can
change any objects property without writing code for each object.
To pass the Tag property to a message box:, assuming the Tag property is
on
the current form:
[quoted text clipped - 44 lines]