Link to home
Start Free TrialLog in
Avatar of Joe
JoeFlag for Canada

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?
Avatar of trbaze
trbaze

Use the AfterUpdate event of the checkboxes.
For Report Required:
If me.ReportRequiredNo=true then     'disable other checkboxes
     me.Reporttype.Enabled=False
     me.Initial.enabled=False
     me.Followup.enabled=False
     me.Final.enabled=False
Else     'enable other check boxes
     me.Reporttype.Enabled=True
     me.Initial.enabled=True
     me.Followup.enabled=True
     me.Final.enabled=True
end if

Open in new window

For the afterupdate event of each of the other checkboxes:
ReportType example
If me.Reporttype=true then    'uncheck the other checkboxes
     me.initial=False
     me.Followup=False
     me.Final=False
end if

Open in new window

Do the same for the other three checkboxes.
Avatar of Dale Fye
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.Enabled = me.chk_ReportReq
    'me.cbo_ReportOptions.Enabled = 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.
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!
Avatar of Joe

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.
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

Open in new window

End Sub
Avatar of Joe

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
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
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
Avatar of Joe

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.