Option1 & Option2 to select only one group for a record.

  • Thread starter Thread starter Joe M
  • Start date Start date
J

Joe M

In a table I have two checkbox - Option1 and Option2 respectively. All new
records will be in either Option1 or Option2. And each options will have
fields correspond to them. Option1 has fields: Cars, Sedan, Wagon. And
Option2 has fields: Motorcycles, scooters, bikes.
How do I do a code so that if Option1 is tick, enable all fields in Option1
group and disable all fields in Option2 group. Vice versa, if Option2 tick,
enable all fields in Option2 group and disable all fields in Option1.
Thanks.
 
Vaught, I cannot use radio buttons because the values enter for fields in
either option group will be variable text record values.
 
Joe, You could use the after update event of your checkbox's to enable/disable the fields like
so.(change names of controls of course)


Private Sub chk1_AfterUpdate()
If Me.chk1 = True Then
Me.txt1.Enabled = True
Me.txt2.Enabled = True
Me.chk2 = False
Me.txt3 = Null
Me.txt4 = Null
Me.txt.Enabled = False
Me.txt.Enabled = False
Else
Me.txt1 = Null
Me.txt2 = Null
Me.txt1.Enabled = False
Me.txt2.Enabled = False
Me.chk2 = False
Me.txt3 = Null
Me.txt4 = Null
Me.txt3.Enabled = False
Me.txt4.Enabled = False
End If
End Sub

Private Sub chk2_AfterUpdate()
If Me.chk2 = True Then
Me.txt3.Enabled = True
Me.txt4.Enabled = True
Me.chk1 = False
Me.txt1 = Null
Me.txt2 = Null
Me.txt1.Enabled = False
Me.txt2.Enabled = False
Else
Me.txt3 = Null
Me.txt4 = Null
Me.txt3.Enabled = False
Me.txt4.Enabled = False
Me.chk1 = False
Me.txt1 = Null
Me.txt2 = Null
Me.txt1.Enabled = False
Me.txt2.Enabled = False
End If
End Sub

Hope this helps!
 
Back
Top