Enable field based on check box

Posted on 2011-02-18
Last Modified: 2012-05-11
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.


Question by:smods
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 14

Expert Comment

by:Bill Ross
ID: 34925241
Hi 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.



Author Comment

ID: 34925253
Thanks Bill.

How would this be achieved?  It's fine that all records will be disabled/enabled.


LVL 14

Accepted Solution

Bill Ross earned 500 total points
ID: 34925269

As a follow up you can use the following code in the AfterUpdate event of the checkboxes to get the idea:

sub CheckBox1_AfterUpdate()
  if me!CheckBox1 = true then
  end if
end sub


The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

LVL 14

Expert Comment

by:Bill Ross
ID: 34925278
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.


LVL 14

Expert Comment

by:Bill Ross
ID: 34925284
OOps typo:


should be

LVL 57
ID: 34925310

  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>.Form.<mycontrolname>.Enabled = me.<checkboxcontrolname>

  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>.Form.<mycontrolname>.Locked = Not me.<checkboxcontrolname>

  last, you can use conditional formatting to block out a field, which gets around a lot of the problems with continuous forms (screenshot attached).  


 Screen shot of blocking out fields on a continious forms

Author Comment

ID: 34925325
I spotted the typo Bill :)

Thanks for your help!


Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question