Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Enable field based on check box

Posted on 2011-02-18
7
Medium Priority
?
868 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
[X]
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
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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

671 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