Object name on user form
Me.ActiveControl on its own returns the default property of the control that
currently has focus, which for most controls is typically False (unless it
has a 'Value' property = true). Though controls such as Textbox, which have
no default property, return an empty string.
Based on user's actions you need to define source and destination textboxes
and what action triggers the copy. Eg, user types text into one textbox,
exits it, enters another, then presses a button (but don't do it like
that!).
In the meantime -
Private Sub UserForm_Click()
Dim ctrl As Object
' with cursor in a textbox that contains text click on form
Set ctrl = Me.ActiveControl
If TypeName(ctrl) = "TextBox" Then
MsgBox ctrl.Text, , ctrl.Name
Else
MsgBox ctrl.Name
End If
End Sub
Regards,
Peter T
"Alan" wrote in message
...
Because there are a number of text boxes (10) I don't know where the
user is or where he/she wants to 'paste' to so I can't use the simple
TextBox3.Value = TextBox1.Value
(In answer to Simon, yes, I am trying to make the value stored in the
'paste' box the same as the 'copy' box but only those selected by the
user, not all of them)
Me.ActiveControl.Name returns the name of the selected box but I am
now having trouble using it as the source in a 'paste' command. How
can I turn this text string into an object? - any further ideas please
Me.ActiveControl simply returns the boolean value 'False' and so is
of no use
Alan
On Jan 2, 11:29 am, Mike H wrote:
Hi,
There's no need for copying and pasting use
TextBox3.Value = TextBox1.Value
This line returns the active control name
Me.ActiveControl.Name
nd this retuns the value
Me.ActiveControl
Mike
|