Solved

Enable field based on check box

Posted on 2011-02-18
7
860 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now