Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Enable field based on check box

Posted on 2011-02-18
7
Medium Priority
?
870 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 2000 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
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!

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

782 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