?
Solved

disabling textboxes

Posted on 2005-05-10
3
Medium Priority
?
212 Views
Last Modified: 2010-05-02
I have two radio buttons. How can I get one of them checked by default? Also how can I get some textboxes disabled and some enabled depending on the radio button selected.  Thanks
0
Comment
Question by:exNavyNuke
  • 2
3 Comments
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 2000 total points
ID: 13967796
Set the Value property to true. To disable and enable use something like this:

Private Sub Option1_Click()
If Option1.Value = True Then
    Text1.Enabled = False
Else
    Text1.Enabled = True
End If
End Sub
0
 
LVL 10

Expert Comment

by:fds_fatboy
ID: 13968090
'In this example 2 radio buttons and 3 textboxes TB1 enabled,TB2 and TB3 disabled when RB1 set; TB1 disabled, TB2 and TB3 disabled when RB2 is set
'If you have two separate radio buttons (not a control array)

Private Sub Form_Load()
   'To set an option button as default
    Option1.Value = True
End Sub

Private Sub Option1_Click()
    Text1.Enabled = Option1.Value
    Text2.Enabled = Not Option1.Value
    Text3.Enabled = Not Option1.Value
End Sub

Private Sub Option2_Click()
    Text1.Enabled = Option1.Value
    Text2.Enabled = Not Option1.Value
    Text3.Enabled = Not Option1.Value
End Sub

0
 
LVL 10

Expert Comment

by:fds_fatboy
ID: 13968131
'Similarly you could save some coding without losing clarity by using a control array for your radio buttons

Private Sub Form_Load()
   'To set an option button as default
    Option1(0).Value = True
End Sub

Private Sub Option1_Click(Index As Integer)
    Text1.Enabled = Option1(0).Value
    Text2.Enabled = Not Option1(0).Value
    Text3.Enabled = Not Option1(0).Value
End Sub
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question