(Msg. 1) Posted: Sat Jun 28, 2008 5:20 pm
Post subject: Detecting or reading the name of a textbox Add to elertz Archived from groups: microsoft>public>word>vba>userforms (more info?)
Hello Everybody
I have two questions:
1.)
In my UserForm I can detect the name of the form, the name of a frame
on that form, but how can I detect (read) the name of a texbox in that
frame?
str_Form = Me.Name
str_Frame = Me.ActiveControl.Name
str_TextBox = (how to do that?)
2.)
How can I detect the name of any textbox whith a mouse click in that
textbox, e.g. with the MouseDown Event?
(Msg. 2) Posted: Sun Jun 29, 2008 3:05 am
Post subject: Re: Detecting or reading the name of a textbox Add to elertz [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Do you really need the textbox inside a frame? If you want to have a group
of textboxes contained within a border, put them inside an empty label to
which you apply a border and then you can use:
Private Sub txtStart_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
MsgBox Me.ActiveControl.Name
End Sub
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
<Sunouchi@> wrote in message
news:46lc6417jlarvdrb1qn6o76h081967nesq@4ax.com...
> Hello Everybody
>
> I have two questions:
>
> 1.)
> In my UserForm I can detect the name of the form, the name of a frame
> on that form, but how can I detect (read) the name of a texbox in that
> frame?
>
> str_Form = Me.Name
> str_Frame = Me.ActiveControl.Name
> str_TextBox = (how to do that?)
>
> 2.)
>
> How can I detect the name of any textbox whith a mouse click in that
> textbox, e.g. with the MouseDown Event?
>
>
> Tanks in advance,
> Hans
(Msg. 3) Posted: Sun Jun 29, 2008 11:40 am
Post subject: Re: Detecting or reading the name of a textbox Add to elertz [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
On Sun, 29 Jun 2008 08:34:33 +1000, "Doug Robbins - Word MVP"
<dkr RemoveThis @REMOVECAPSmvps.org> wrote:
>Do you really need the textbox inside a frame? If you want to have a group
>of textboxes contained within a border, put them inside an empty label to
>which you apply a border and then you can use:
>
>Private Sub txtStart_MouseDown(ByVal Button As Integer, ByVal Shift As
>Integer, ByVal X As Single, ByVal Y As Single)
>MsgBox Me.ActiveControl.Name
>End Sub
Thanks for your answer, but a frame is more convenient. I can easily
replace the content at once to another position on the form. This is
difficult with a label.
If I want to move the textboxes within the label, the label will be
selected as well, wicht makes things difficult.
Besides that, some of the textboxes are created at run time,
dynamically. So, in that case your routine is not applicable, because
at design time the textbox doesn't exist.
From your answer, can I say that it is impossible to detect the name
of a textbox in a frame?
(Msg. 4) Posted: Mon Jun 30, 2008 3:03 am
Post subject: Re: Detecting or reading the name of a textbox Add to elertz [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
I could not find a way to do it, but that may only mean the method is
elusive, not impossible.
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
<Sunouchi@> wrote in message
news:e4le64179dg8s427ooomkaib37pral2akc@4ax.com...
> On Sun, 29 Jun 2008 08:34:33 +1000, "Doug Robbins - Word MVP"
> <dkr RemoveThis @REMOVECAPSmvps.org> wrote:
>
>>Do you really need the textbox inside a frame? If you want to have a
>>group
>>of textboxes contained within a border, put them inside an empty label to
>>which you apply a border and then you can use:
>>
>>Private Sub txtStart_MouseDown(ByVal Button As Integer, ByVal Shift As
>>Integer, ByVal X As Single, ByVal Y As Single)
>>MsgBox Me.ActiveControl.Name
>>End Sub
>
> Thanks for your answer, but a frame is more convenient. I can easily
> replace the content at once to another position on the form. This is
> difficult with a label.
> If I want to move the textboxes within the label, the label will be
> selected as well, wicht makes things difficult.
> Besides that, some of the textboxes are created at run time,
> dynamically. So, in that case your routine is not applicable, because
> at design time the textbox doesn't exist.
>
> From your answer, can I say that it is impossible to detect the name
> of a textbox in a frame?
>
> All the best,
> Hans
(Msg. 5) Posted: Mon Jun 30, 2008 4:34 pm
Post subject: Re: Detecting or reading the name of a textbox Add to elertz [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Hi Hans,
Doug accesses the active control of the userform,
which is the frame.
You may try to access the activecontrol in the frame, like that:
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If Me.ActiveControl.name = "Frame1" Then
MsgBox Me.Frame1.ActiveControl.name
End If
End Sub
which requires two mouseclicks,
on in the textbox in the frame,
one click outside the frame.
(Msg. 6) Posted: Mon Jun 30, 2008 4:38 pm
Post subject: Re: Detecting or reading the name of a textbox Add to elertz [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Also possible,
Private Sub Frame1_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
MsgBox Me.Frame1.ActiveControl.name
End Sub
which requires a second mouseclick inside the frame
after the cursor was put into a textbox in the frame.
(Msg. 7) Posted: Mon Jun 30, 2008 6:49 pm
Post subject: Re: Detecting or reading the name of a textbox Add to elertz [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
How can I detect the name of any textbox whith a mouse click in that textbox,
e.g. with the MouseDown Event?
By using the MouseDown for that textbox. I am not sure why the others are
using the userform MouseDown. The code below assumes that TextBox1 is in
Frame1.
Private Sub TextBox1_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, _
ByVal X As Single, _
ByVal Y As Single)
Label1.Caption = Me.Frame1.ActiveControl.Name
End Sub
would write the name ("TextBox1") to the Label caption, when you click into
the textbox.
Sunouchi@ wrote:
>Hello Everybody
>
>I have two questions:
>
>1.)
>In my UserForm I can detect the name of the form, the name of a frame
>on that form, but how can I detect (read) the name of a texbox in that
>frame?
>
> str_Form = Me.Name
> str_Frame = Me.ActiveControl.Name
> str_TextBox = (how to do that?)
>
>2.)
>
>How can I detect the name of any textbox whith a mouse click in that
>textbox, e.g. with the MouseDown Event?
>
>Tanks in advance,
>Hans
(Msg. 8) Posted: Mon Jun 30, 2008 6:50 pm
Post subject: Re: Detecting or reading the name of a textbox Add to elertz [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
That is, only one mouse click is required. You click into the textbox, the
name is written to the label. One click.
fumei wrote:
>How can I detect the name of any textbox whith a mouse click in that textbox,
>e.g. with the MouseDown Event?
>
>By using the MouseDown for that textbox. I am not sure why the others are
>using the userform MouseDown. The code below assumes that TextBox1 is in
>Frame1.
>
>Private Sub TextBox1_MouseDown(ByVal Button As Integer, _
> ByVal Shift As Integer, _
> ByVal X As Single, _
> ByVal Y As Single)
>
> Label1.Caption = Me.Frame1.ActiveControl.Name
>End Sub
>
>would write the name ("TextBox1") to the Label caption, when you click into
>the textbox.
>
>>Hello Everybody
>>
>[quoted text clipped - 16 lines]
>>Tanks in advance,
>>Hans
All times are: Eastern Time (US & Canada) (change) Goto page 1, 2
Page 1 of 2
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum