Link to home
Start Free TrialLog in
Avatar of dwe0608
dwe0608Flag for Australia

asked on

URGENT: Best Coding Practise - # 1


I have a series of checkboxes on a form - I need to test the value of one of two fields on the click event ... I currently do it as follows :

Private Sub chkFields_Click(Index As Integer)
    Select Case Index
        Case 7
            If chkFields(7).Value = vbChecked Then
               chkFields(8).Value = vbUnchecked
            Else
               chkFields(8).Value = vbChecked
            End If
        Case 8
            If chkFields(8).Value = vbChecked Then
               chkFields(7).Value = vbUnchecked
            Else
               chkFields(7).Value = vbChecked
            End If
    End Select

End Sub

Is there a simpler (ie shorter coding) way of achieving this ?

What is the best coding practise to achieve the result ?

MTIA
Avatar of pradapkumar
pradapkumar

If you wish to test only two check boxes those which you are having, Then try to use Option button(Radio button) with a frame control to group them logically.
for example you have only 2 options to select 4 a particular problem like sex add a frame and draw 2 option buttons in it. then use it without coding like above. Because user only will be permitted to select either one of the option button from a group without any extra coding.
ASKER CERTIFIED SOLUTION
Avatar of BrianGEFF719
BrianGEFF719
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial