ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select option button when have the name as a string (https://www.excelbanter.com/excel-programming/321071-select-option-button-when-have-name-string.html)

Debbie Probert via OfficeKB.com

Select option button when have the name as a string
 
Hi All

During the running of my VBA code, I collect the name of an option button from an Access database. I then want to set the value of the option button on a form. My problem is that I have the name of the button as a string and just cannot see how to use that to set the value of the button on the form as, when used as a string, I get an error.

Hope the question makes sense to someone :-)

Many thanks
Deb

--
Message posted via http://www.officekb.com

Bob Phillips[_7_]

Select option button when have the name as a string
 
Deb,

Use
Me.Controls(string_value)

with whatever property you want

--
HTH

Bob Phillips

"Debbie Probert via OfficeKB.com" wrote in message
...
Hi All

During the running of my VBA code, I collect the name of an option button

from an Access database. I then want to set the value of the option button
on a form. My problem is that I have the name of the button as a string and
just cannot see how to use that to set the value of the button on the form
as, when used as a string, I get an error.

Hope the question makes sense to someone :-)

Many thanks
Deb

--
Message posted via http://www.officekb.com




Tom Ogilvy

Select option button when have the name as a string
 
Private Sub CommandButton2_Click()
sStr = "Button Name"
UserForm1.Optionbutton1.Caption = sStr
End Sub

I assume by name you mean the name you would see next to the button on the
form.

--
Regaards,
Tom Ogilvy



"Debbie Probert via OfficeKB.com" wrote in message
...
Hi All

During the running of my VBA code, I collect the name of an option button

from an Access database. I then want to set the value of the option button
on a form. My problem is that I have the name of the button as a string and
just cannot see how to use that to set the value of the button on the form
as, when used as a string, I get an error.

Hope the question makes sense to someone :-)

Many thanks
Deb

--
Message posted via http://www.officekb.com





All times are GMT +1. The time now is 01:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com