Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

option button group

Status
Not open for further replies.

ironj32

Technical User
Dec 7, 2006
73
0
0
US
Tried posting this in the VBA for Microsoft forum but no luck.
In an excel userform that i have a group of option buttons with the GroupName of "SelectOne".
It contains 4 optbuttons:
optNewContract
optRenewContract
optUpdatedContract
optReplaceVendor
I also have a txtbox..."txtReplacedVendor"

I want txtReplacedVendor to be only enabled when optReplaceVendor is selected. I have tried If Then statements but have not had luck. I have gotten it so that when
optReplaceVendor = true then the focus is set to txtReplacedVendor. The problem i am having is that the txtbox is still enabled when the other options are selected.
Thanks for any help.
 



hi,

"I have tried If Then statements but have not had luck. "

What code did you try? Please post.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 

Code:
Private Sub optReplaceVendor_click()
If optReplaceVendor = True Then
txtReplacedVendor.SetFocus
Else
txtReplacedVendor.Enabled = False
End If
End Sub
 
If I remeber correctly, Option Groups in Access work based on a Value. Each control (radio button or check box) in the option group is assigned a value. When a selection is made in the option group, the option group itself has its value set to the value of the item that was checked.

For example, an option group called Group1 has two radio buttons, Radio1 with a value of 1 and Radio2 with a value of 2. When you select Radio1, Group1 value becomes 1 and when you select Radio2, Group1 value becomes 2.

Therefore, you can check the value of the option group:

Code:
If Group1.Value = [i]x[/i] Then
    txtReplacedVendor.Enabled = True
Else
    txtReplacedVendor.Enabled = False
End If

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
Thanks for you help. I guess firstly I need to have this question answered before I move on to the IF Statements.
This is also a thread from the other forum. thanks!

thread707-1332575
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top