how can enable or disable certain control on the form depending upon

  • Thread starter Thread starter anj
  • Start date Start date
A

anj

Dear All
Thanks in advance!
I would like to know if anyone can help me get the code to
programmatically enable or disable certain controls on the
form depending upon the selection of option button from a
option group ?
 
(untested aircode - your syntax may vary):

Me!txtMyControl.Enabled = (Me!grpMyOption = 1)

should set the enabled property to True when option 1 was chosen.

For this to work every time the option group changes, you'd need to put it
in the AfterUpdate event of the option group.
 
Thanks a lot Jeff!
I tried as you suggested but it is not working.
I used both After and Before Update event procedure to
test but gives error and points to unknown or invalid
option button if I understand the pop out error message
correctly.
"Frame0" Option group contains 3 option buttons
(ABCCouriers, SpeedDelivery and LightningDelivery)and one
checkbox "check9" and used the code like the following as
you suggested:

Private Sub Frame0_BeforeUpdate(Cancel As Integer)
Me!Check9.Enabled = (Me!ABCCouriers = 1)
End Sub
or
Private Sub Frame0_AfterUpdate(Cancel As Integer)
Me!Check9.Enabled = (Me!ABCCouriers = 1)
End Sub



Error is like this "Procedure declaration doesn't match
description of event or procedure having the same name"

Hope I have made myself clear!
 
Thanks Jeff!
I was able to do it.
Actually I was making mistake by putting one of option
button ("ABCCouriers") instead of option group name
("Frame0") on the right side of "=" in the code.
Thanks a lot!

Now I want to know how can I restrict selection of option
button when the option group gets focus. I want to option
group remain unselected i.e. there shouldn't any selection
of option button until I check one button.
 
As I recall, the option group has a "default" property. I don't know if you
can leave out a value...

Jeff Boyce
<Access MVP>
 
Back
Top