smods
asked on
Enable field based on check box
Hi all,
I have a continuous subform with a 10 fields. I want to add ten tick boxes and set all the fields to not be enabled by default which I've set in the properties of each of the fields. Now I need the code to say that if the tick box for that field is checked that the field becomes enabled.
How would I do this code wise?
The check boxes will be unbound and when I close the main form the subform is on all checkboxes need to be unticked.
Thanks
Chris
I have a continuous subform with a 10 fields. I want to add ten tick boxes and set all the fields to not be enabled by default which I've set in the properties of each of the fields. Now I need the code to say that if the tick box for that field is checked that the field becomes enabled.
How would I do this code wise?
The check boxes will be unbound and when I close the main form the subform is on all checkboxes need to be unticked.
Thanks
Chris
ASKER
Thanks Bill.
How would this be achieved? It's fine that all records will be disabled/enabled.
Regards
Chris
How would this be achieved? It's fine that all records will be disabled/enabled.
Regards
Chris
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi again Chris,
Make sure all checkboxes have a default value of false so they will always open unchecked and make sure that all fields have a default property enabled = true so the form opens enabled and unchecked.
Regards,
Bill
Make sure all checkboxes have a default value of false so they will always open unchecked and make sure that all fields have a default property enabled = true so the form opens enabled and unchecked.
Regards,
Bill
OOps typo:
me!yourfieldname.exnabled= true
should be
me!yourfieldname.enabled=t rue
me!yourfieldname.exnabled=
should be
me!yourfieldname.enabled=t
As Bill has said, you'll need to run some code, but you'll want to do this in the AfterUpdate event of the checkboxes. And the other issue is the continuous form. For the controls to be treated individually, they must be bound.
After re-reading your question, what I would suggest is a main / subform combination (and this may be what you already have). Place the check boxes on the main form, which can be bound or unbound (just leave the check boxes unbound).
Then in the AfterUpdate event of each:
Me.<subformcontrolname>.Fo
You also might want to set the locked property in addition to the Enabled property. When setting enabled to false, a control is "grayed out". Setting the lock property to true makes it look like a normal control. That would be done with:
Me.<subformcontrolname>.Fo
last, you can use conditional formatting to block out a field, which gets around a lot of the problems with continuous forms (screenshot attached).
JimD.
ASKER
I spotted the typo Bill :)
Thanks for your help!
Chris
Thanks for your help!
Chris
In a continuous form if you enable/disable a field it is disabled for all records. There is only a single field displayed "continuously".
You can handle the process with a before update on the specific fields that should be enabled/disabled by testing the various check boxes for conditions.
Regards,
Bill