Assign a radio button's tag property to a text variable txBtn

M

marc

Below is some code from a form that I'm making.
I inserted my question in the bracketted text
(essentially, I want this line to assign the button's tag
property value (e.g., the letter "L") to a text variable
txBtn).
Any help would be appreciated.
fyi, I'm defining the text variable txBtn in the
subroutine that calls the form, as follows: dim txBtn as
text. Another subroutine (InsertRorCInTable) will use
the value assigned to txBtn, in determining whether to
insert a row above or below, or a column to the right or
to the left.
Here's the code.....

Private Sub radInsertColLt_Click()
[I want this line to assign the button's tag
property value (i.e., the letter "L") to a text variable
txBtn, but I can't figure out how to do it]
Call InsertRorCInTable
End Sub
Private Sub radInsertColLt_DblClick(ByVal Cancel As
MSForms.ReturnBoolean)
[I want this line to assign the button's tag
property value (i.e., the letter "L") to a text variable
txBtn, but I can't figure out how to do it]
Call InsertRorCInTable
End Sub
 
S

Stan Scott

Marc,

Let me ask first -- are there two buttons: one to insert left and one to
insert right?? If this is true, just use InsertRorCInTable
("L") for one button and InsertRorCInTable("R") for the other, and set the
argument in the called routine.

If this isn't the case, I think you should provide a bit more information --
it probably isn't necessary to use the tag property at all.

OTOH, if you really really want to use this method, here's the HELP
explanation from Excel:

Tag Property Example

The following example uses the Tag property to store additional information
about each control on the UserForm. The user clicks a control and then
clicks the CommandButton. The contents of Tag for the appropriate control
are returned in the TextBox.

To use this example, copy this sample code to the Declarations portion of a
form. Make sure that the form contains:

a.. A TextBox named TextBox1.


b.. A CommandButton named CommandButton1.


c.. A ScrollBar named ScrollBar1.


d.. A ComboBox named ComboBox1.


e.. A MultiPage named MultiPage1.
Private Sub CommandButton1_Click()
TextBox1.Text = ActiveControl.Tag
End Sub

Private Sub UserForm_Initialize()
TextBox1.Locked = True
TextBox1.Tag = "Display area for Tag properties."
TextBox1.AutoSize = True

CommandButton1.Caption = "Show Tag of Current " _
& "Control."
CommandButton1.AutoSize = True
CommandButton1.WordWrap = True
CommandButton1.TakeFocusOnClick = False
CommandButton1.Tag = "Shows tag of control " _
& "that has the focus."

ComboBox1.Style = fmStyleDropDownList
ComboBox1.Tag = "ComboBox Style is that of " _
& "a ListBox."

ScrollBar1.Max = 100
ScrollBar1.Min = -273
ScrollBar1.Tag = "Max = " & ScrollBar1.Max _
& " , Min = " & ScrollBar1.Min

MultiPage1.Pages.Add
MultiPage1.Pages.Add
MultiPage1.Tag = "This MultiPage has " _
& MultiPage1.Pages.Count & " pages."
End SubStan Scott
New York City
Below is some code from a form that I'm making.
I inserted my question in the bracketted text
(essentially, I want this line to assign the button's tag
property value (e.g., the letter "L") to a text variable
txBtn).
Any help would be appreciated.
fyi, I'm defining the text variable txBtn in the
subroutine that calls the form, as follows: dim txBtn as
text. Another subroutine (InsertRorCInTable) will use
the value assigned to txBtn, in determining whether to
insert a row above or below, or a column to the right or
to the left.
Here's the code.....

Private Sub radInsertColLt_Click()
[I want this line to assign the button's tag
property value (i.e., the letter "L") to a text variable
txBtn, but I can't figure out how to do it]
Call InsertRorCInTable
End Sub
Private Sub radInsertColLt_DblClick(ByVal Cancel As
MSForms.ReturnBoolean)
[I want this line to assign the button's tag
property value (i.e., the letter "L") to a text variable
txBtn, but I can't figure out how to do it]
Call InsertRorCInTable
End Sub
 
G

Guest

1. Thank you. I'll study your reply later this evening.
In the interim (to answer your questions)....
2. I have 4 buttons:
("L") for one button (radInsertColLt)
("R") for one button (radInsertColRt)
("A") for one button (radInsertRowAbove)
("B") for one button (radInsertRowBelow)
in a frame .....
plus (two more buttons, i.e.,)
Okay and Cancel
3. The idea of using the tag property appealed to me
because it might obviate the need for me to create a
variable. OTHO, having briefly perused the
code you so kindly sent to me, I suspect that it
would be a lot easier to simply have each button
assign a letter to a memory variable, before the
button calls a macro which uses the variable to
decide what action to take.
Thanks again,

Marc
-----Original Message-----
Marc,

Let me ask first -- are there two buttons: one to insert left and one to
insert right?? If this is true, just use InsertRorCInTable
("L") for one button and InsertRorCInTable("R") for the other, and set the
argument in the called routine.

If this isn't the case, I think you should provide a bit more information --
it probably isn't necessary to use the tag property at all.

OTOH, if you really really want to use this method, here's the HELP
explanation from Excel:

Tag Property Example

The following example uses the Tag property to store additional information
about each control on the UserForm. The user clicks a control and then
clicks the CommandButton. The contents of Tag for the appropriate control
are returned in the TextBox.

To use this example, copy this sample code to the Declarations portion of a
form. Make sure that the form contains:

a.. A TextBox named TextBox1.


b.. A CommandButton named CommandButton1.


c.. A ScrollBar named ScrollBar1.


d.. A ComboBox named ComboBox1.


e.. A MultiPage named MultiPage1.
Private Sub CommandButton1_Click()
TextBox1.Text = ActiveControl.Tag
End Sub

Private Sub UserForm_Initialize()
TextBox1.Locked = True
TextBox1.Tag = "Display area for Tag properties."
TextBox1.AutoSize = True

CommandButton1.Caption = "Show Tag of Current " _
& "Control."
CommandButton1.AutoSize = True
CommandButton1.WordWrap = True
CommandButton1.TakeFocusOnClick = False
CommandButton1.Tag = "Shows tag of control " _
& "that has the focus."

ComboBox1.Style = fmStyleDropDownList
ComboBox1.Tag = "ComboBox Style is that of " _
& "a ListBox."

ScrollBar1.Max = 100
ScrollBar1.Min = -273
ScrollBar1.Tag = "Max = " & ScrollBar1.Max _
& " , Min = " & ScrollBar1.Min

MultiPage1.Pages.Add
MultiPage1.Pages.Add
MultiPage1.Tag = "This MultiPage has " _
& MultiPage1.Pages.Count & " pages."
End SubStan Scott
New York City
"(e-mail address removed)"
Below is some code from a form that I'm making.
I inserted my question in the bracketted text
(essentially, I want this line to assign the button's tag
property value (e.g., the letter "L") to a text variable
txBtn).
Any help would be appreciated.
fyi, I'm defining the text variable txBtn in the
subroutine that calls the form, as follows: dim txBtn as
text. Another subroutine (InsertRorCInTable) will use
the value assigned to txBtn, in determining whether to
insert a row above or below, or a column to the right or
to the left.
Here's the code.....

Private Sub radInsertColLt_Click()
[I want this line to assign the button's tag
property value (i.e., the letter "L") to a text variable
txBtn, but I can't figure out how to do it]
Call InsertRorCInTable
End Sub
Private Sub radInsertColLt_DblClick(ByVal Cancel As
MSForms.ReturnBoolean)
[I want this line to assign the button's tag
property value (i.e., the letter "L") to a text variable
txBtn, but I can't figure out how to do it]
Call InsertRorCInTable
End Sub


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top