Solved

Enable field based on check box

Posted on 2011-02-18
7
862 Views
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.

Thanks

Chris
0
Comment
Question by:smods
  • 4
  • 2
7 Comments
 
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.

Regards,

Bill
0
 

Author Comment

by:smods
ID: 34925253
Thanks Bill.

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

Regards

Chris
0
 
LVL 14

Accepted Solution

by:
Bill Ross earned 500 total points
ID: 34925269
Hi,

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
    me!yourfieldname.exnabled=true
  else
    me!yourfieldname.exnabled=false
  end if
end sub

Regards,

Bill
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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.

Regards,

Bill
0
 
LVL 14

Expert Comment

by:Bill Ross
ID: 34925284
OOps typo:

me!yourfieldname.exnabled=true

should be

me!yourfieldname.enabled=true
0
 
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).  

JimD.

 Screen shot of blocking out fields on a continious forms
0
 

Author Comment

by:smods
ID: 34925325
I spotted the typo Bill :)

Thanks for your help!

Chris
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

820 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