[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 688
  • Last Modified:

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?
0
Joe
Asked:
Joe
  • 4
  • 3
  • 2
1 Solution
 
trbazeCommented:
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.
0
 
Dale FyeCommented:
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.
0
 
trbazeCommented:
fyed is right.  The option group is the easiest way.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Dale FyeCommented:
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!
0
 
JoeAuthor Commented:
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.
0
 
Dale FyeCommented:
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
0
 
JoeAuthor Commented:
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
0
 
Dale FyeCommented:
I usually use the click event of the checkbox, but believe AfterUpdate will work as well.  Sorry, I forgot to change the Enable to True in bottom half of the If statement in my previous post.
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 = True
    end if

End Sub

Open in new window

0
 
JoeAuthor Commented:
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.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now