Joe
asked on
Enabling/Disabling Form fields based on
I have an entry form in MS Access 2003 that requires users to make certain selections for tracking purposes.
I have two (2) check boxes that indicate whether a report is required and based on that entry 3 additional check boxes and at least one date field that requires data
Looking at the attached screen shot:
If the user selects the "Report required No" checkbox, I would like the
"Report Type - Initial, Follow-up, Final" checkboxes disabled.
If the user selects the "Report required yes" checkbox, I would like the
"Report Type - Initial, Follow-up, Final" checkboxes enabled AND only one of the three can be selected. In other words you can not have initial, follow-up and final alll selected at once.
Is this possible and if so, how?
I have two (2) check boxes that indicate whether a report is required and based on that entry 3 additional check boxes and at least one date field that requires data
Looking at the attached screen shot:
If the user selects the "Report required No" checkbox, I would like the
"Report Type - Initial, Follow-up, Final" checkboxes disabled.
If the user selects the "Report required yes" checkbox, I would like the
"Report Type - Initial, Follow-up, Final" checkboxes enabled AND only one of the three can be selected. In other words you can not have initial, follow-up and final alll selected at once.
Is this possible and if so, how?
no screen shot attached.
1. First, since users should not be able to select both Report Required Yes and No, I would change that to simply a single checkbox or combo box (Report Required). If checkbox, checked indicates yes, unchecked indicates no.
If you choose to use the checkbox option, I would use the checkboxes Click event, something like:
Private sub chk_ReportReq_Click
me.og_ReportOptions.Enable d = me.chk_ReportReq
'me.cbo_ReportOptions.Enab led = me.chk_ReportReq
End Sub
This would enable/disable the option group (or combo box) mentioned below.
2. For the report types options. I would either use a combo box, with options Initial or Follup, or Final. Or you could use an option group (frame) and use radio buttons instead of checkboxes. This way, the user can only select one item at a time.
1. First, since users should not be able to select both Report Required Yes and No, I would change that to simply a single checkbox or combo box (Report Required). If checkbox, checked indicates yes, unchecked indicates no.
If you choose to use the checkbox option, I would use the checkboxes Click event, something like:
Private sub chk_ReportReq_Click
me.og_ReportOptions.Enable
'me.cbo_ReportOptions.Enab
End Sub
This would enable/disable the option group (or combo box) mentioned below.
2. For the report types options. I would either use a combo box, with options Initial or Follup, or Final. Or you could use an option group (frame) and use radio buttons instead of checkboxes. This way, the user can only select one item at a time.
fyed is right. The option group is the easiest way.
Personally, I prefer combo boxes because they take up less space and my users can simply type one or two characters and hit enter to make a selection. With checkboxes and option groups, the hands have to leave the keyboard, and in my opinion, good form design will make it easy for someone to enter all of the information they need to without their hands leaving the keyboard.
But that's just me!
But that's just me!
ASKER
So based on the above solution(s) let's say I fine-tune my database a little to decrease some overhead and remove the curent five stored fields to two:
- Report_Required (Yes/No) - single check box - No by default
and
- Report_Type - OptionGroup - Initial, Follow-up, Final
Users would have to check the YES checkbox to enable the Report_Type Option Group
if the Report_Required checkbox is selected then the Report_Type group becomes active
If the Report_Required checkbox is cleared, the Report_Type Option Group is cleared and disabled.
I hope I have explained my intent clearly and appreciate the assistance.
- Report_Required (Yes/No) - single check box - No by default
and
- Report_Type - OptionGroup - Initial, Follow-up, Final
Users would have to check the YES checkbox to enable the Report_Type Option Group
if the Report_Required checkbox is selected then the Report_Type group becomes active
If the Report_Required checkbox is cleared, the Report_Type Option Group is cleared and disabled.
I hope I have explained my intent clearly and appreciate the assistance.
Your radio buttons in the option group would each have a numeric value (I normally use 1,2,3), but they could be any value you want to give them. The value of the option group would not be automatically cleared when you uncheck the ReportRequired checkbox. You would have to do that in your code, something like:
Private sub chk_Report_Required_Click
if me.chk_Report_Required = False then
me.og_Report_Type = Null
me.og_Report_Type.Enabled = False
else
me.og_Report_Type.Enabled = False
end if
End Sub
End Sub
ASKER
Sorry for being a pain.
Which code do I use and where do I place it to enable and disable the Report_Type Group based on the the Report_Required check box
Which code do I use and where do I place it to enable and disable the Report_Type Group based on the the Report_Required check box
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I truly appreciate the prompt assistance with this issue. Not only did this solve my problem; it helped me to prune down the fields in my db as well.
For Report Required:
Open in new window
For the afterupdate event of each of the other checkboxes:ReportType example
Open in new window
Do the same for the other three checkboxes.