gray checkboxes

G

Guest

I have been searching for a way to gray out other checkboxes bases on a
single selection. Last week I tried several and none worked. I was even
advised to look into radio buttons but they didn't work either. So far the
message below is the one closest to what I am doing except it does it
backwards!! When I write and place the code as explained below it enables me
to check box one and then it activates box 2 and box 3 instead of
deactivating them!! I am flustered rewriting this one! Any suggestion on
where I going wrong?

Thanks in advance!!
Myron


PREVIOUS MESSAGE I USED BELOW: (it reads from the bottom up)
Yep, I sure did. Sorry about that.

The code works great now. Thank you both, Fred & Marshall.

Marshall Barton said:
It sounds like you skipped Fred's second step about the
Current event.
--
Marsh
MVP [MS Access]


Ken said:
The checkbox fields now work to a point: When I toggle the "master yes/no"
checkbox the others will go gray/black as they should.

However, as I scroll through records, this conditional formatting is not
remembered. That is, I often come to a record where the master yes/no is
"no" but the other boxes are black, or master yes/no is "yes" but the others
are grayed out. It does not remember and automatically interpret the master
yes/no unless it is updated.

Is there a way for the format to be attached to another event that will keep
it each time I go to a new record AND update a current record?

On Fri, 23 Sep 2005 14:50:16 -0700, Ken Cobler wrote:
I have several checkboxes on a Form. The first checkbox is a general yes/no
choice. If the answer is "no" on this checkbox, I would like all the other
checkboxes to be grayed-out. If the answer is "yes", then the other detailed
checkboxes would be black and allow for further yes/no responses.
fredg said:
First, set the Enabled property of all the check boxes (except the
general one) to No.

Then code the AfterUpdate event of the first check box:

Me![CheckBox2].enabled = Me![CheckBox1]
Me![CheckBox3].enabled = Me![CheckBox1]
Me![CheckBox4].enabled = Me![CheckBox1]

Place the same code in the Form's Current event.
 
G

Guest

Radio buttons are what you need, the principle is that whenever one is
pressed it replaces the current selection.
You need to set them up in an option group.
Look up OPTION GROUP in Access Help (Included below).
Look at the how to set it up with the wizard.

- Dorian

Create an option group
You can create an option group on your own or, if you are working in a form
or report, you can use a wizard to create an option group. A wizard speeds up
the process of creating an option group because it does all the basic work
for you. When you use a wizard, Microsoft Access prompts you for information,
and then creates an option group based on your answers.

In a data access page, you use option buttons to represent the different
values that you can save in the underlying field of the option group. In a
form or report, you can use check boxes, option buttons, or toggle buttons to
represent the different values that you can save in the underlying field.

Create an option group by using a wizard

Open a form or report in Design view.
Click the Control Wizards tool in the toolbox if it's not already selected.
In the toolbox, click the Option Group tool .
On the form or report, click where you want to place the upper-left corner
of the option group.
Follow the directions in the wizard dialog boxes. In the last dialog box,
click Finish to display the option group in Design view.
Create an option group on my own

Open a form, report, or data access page in Design view.
Click the Control Wizards tool in the toolbox if it's selected. This turns
off the wizard.
In the toolbox, click the Option Group tool .
Do one of the following:
To create an unbound option group, click where you want to place the group
frame.

To create a bound option group, click Field List on the toolbar to display
the field list, and then drag the appropriate field or column from the field
list to the form, report, or data access page.

Note The control won't be bound if you try to create it by clicking the
form, report, or data access page instead of dragging the selected field from
the field list.

In the form or report toolbox, click the Check Box , Option Button , or the
Toggle Button tool . In the data access page toolbox, click the Option Button
tool.
Click inside the group frame where you want the upper-left corner of the
check box, option button, or toggle button to appear.
Do one of the following:

On a form or report, if necessary, click the control, click Properties on
the toolbar, and then change the OptionValue property to the value that you
want the option group to have when you click that control. When you add the
first control to an option group on a form or report, Microsoft Access sets
its OptionValue property to 1.

On a data access page, click the option button, click Properties on the
toolbar, and then change the Value property from on to the value that you
want the option group to have when you click that button.

If the option group is bound, the value of the control's OptionValue or
Value property is the value that Microsoft Access stores in the underlying
table when you click that control.



OptionValue or Value property set to 1 - clicking this button sets the
value of the Ship Via option group to 1 and, if the option group is bound,
stores that value in the underlying table.

OptionValue or Value property set to 2 - clicking this button sets the
value of the Ship Via option group to 2 and, if the option group is bound,
stores that value in the underlying table.

OptionValue or Value property set to 3 - clicking this button sets the
value of the Ship Via option group to 3 and, if the option group is bound,
stores that value in the underlying table.

Repeat steps 5 through 7 for each control you add to the option group. On a
form or report, Access sets the OptionValue property of the second control to
2, the third to 3, and so on.
Tip

To facilitate data entry, you can make the most commonly chosen option the
default by setting the DefaultValue property of the option group.


Dorian

Myron Mummey said:
I have been searching for a way to gray out other checkboxes bases on a
single selection. Last week I tried several and none worked. I was even
advised to look into radio buttons but they didn't work either. So far the
message below is the one closest to what I am doing except it does it
backwards!! When I write and place the code as explained below it enables me
to check box one and then it activates box 2 and box 3 instead of
deactivating them!! I am flustered rewriting this one! Any suggestion on
where I going wrong?

Thanks in advance!!
Myron


PREVIOUS MESSAGE I USED BELOW: (it reads from the bottom up)
Yep, I sure did. Sorry about that.

The code works great now. Thank you both, Fred & Marshall.

Marshall Barton said:
It sounds like you skipped Fred's second step about the
Current event.
--
Marsh
MVP [MS Access]


Ken said:
The checkbox fields now work to a point: When I toggle the "master yes/no"
checkbox the others will go gray/black as they should.

However, as I scroll through records, this conditional formatting is not
remembered. That is, I often come to a record where the master yes/no is
"no" but the other boxes are black, or master yes/no is "yes" but the others
are grayed out. It does not remember and automatically interpret the master
yes/no unless it is updated.

Is there a way for the format to be attached to another event that will keep
it each time I go to a new record AND update a current record?


On Fri, 23 Sep 2005 14:50:16 -0700, Ken Cobler wrote:
I have several checkboxes on a Form. The first checkbox is a general yes/no
choice. If the answer is "no" on this checkbox, I would like all the other
checkboxes to be grayed-out. If the answer is "yes", then the other detailed
checkboxes would be black and allow for further yes/no responses.

:
First, set the Enabled property of all the check boxes (except the
general one) to No.

Then code the AfterUpdate event of the first check box:

Me![CheckBox2].enabled = Me![CheckBox1]
Me![CheckBox3].enabled = Me![CheckBox1]
Me![CheckBox4].enabled = Me![CheckBox1]

Place the same code in the Form's Current event.
 
F

fredg

I have been searching for a way to gray out other checkboxes bases on a
single selection. Last week I tried several and none worked. I was even
advised to look into radio buttons but they didn't work either. So far the
message below is the one closest to what I am doing except it does it
backwards!! When I write and place the code as explained below it enables me
to check box one and then it activates box 2 and box 3 instead of
deactivating them!! I am flustered rewriting this one! Any suggestion on
where I going wrong?

Thanks in advance!!
Myron

PREVIOUS MESSAGE I USED BELOW: (it reads from the bottom up)
Yep, I sure did. Sorry about that.

The code works great now. Thank you both, Fred & Marshall.

Marshall Barton said:
It sounds like you skipped Fred's second step about the
Current event.
--
Marsh
MVP [MS Access]

Ken said:
The checkbox fields now work to a point: When I toggle the "master yes/no"
checkbox the others will go gray/black as they should.

However, as I scroll through records, this conditional formatting is not
remembered. That is, I often come to a record where the master yes/no is
"no" but the other boxes are black, or master yes/no is "yes" but the others
are grayed out. It does not remember and automatically interpret the master
yes/no unless it is updated.

Is there a way for the format to be attached to another event that will keep
it each time I go to a new record AND update a current record?


On Fri, 23 Sep 2005 14:50:16 -0700, Ken Cobler wrote:
I have several checkboxes on a Form. The first checkbox is a general yes/no
choice. If the answer is "no" on this checkbox, I would like all the other
checkboxes to be grayed-out. If the answer is "yes", then the other detailed
checkboxes would be black and allow for further yes/no responses.

:
First, set the Enabled property of all the check boxes (except the
general one) to No.

Then code the AfterUpdate event of the first check box:

Me![CheckBox2].enabled = Me![CheckBox1]
Me![CheckBox3].enabled = Me![CheckBox1]
Me![CheckBox4].enabled = Me![CheckBox1]

Place the same code in the Form's Current event.

So just reverse the logic.

Me![CheckBox2].enabled = NOT Me![CheckBox1]
Me![CheckBox3].enabled = NOT Me![CheckBox1]
Me![CheckBox4].enabled = NOT Me![CheckBox1]
 
G

Guest

Great news!! It works!! Almost...I say that with a smile! Okay, the radio
buttons only allow you to choose one option and thats really what is needed.
The only thing left to do now is make the unchosen buttons turn gray when one
is selected. I know you may be thinking why? Its a boss thing, he's really
hung up on graying out all the rest!! Something he saw on a web site and
won't let go of! Any ideas? Thanks for all you help so far, I really
appreciate it!! Happy Holidays!!!
Myron

Myron Mummey said:
I have been searching for a way to gray out other checkboxes bases on a
single selection. Last week I tried several and none worked. I was even
advised to look into radio buttons but they didn't work either. So far the
message below is the one closest to what I am doing except it does it
backwards!! When I write and place the code as explained below it enables me
to check box one and then it activates box 2 and box 3 instead of
deactivating them!! I am flustered rewriting this one! Any suggestion on
where I going wrong?

Thanks in advance!!
Myron


PREVIOUS MESSAGE I USED BELOW: (it reads from the bottom up)
Yep, I sure did. Sorry about that.

The code works great now. Thank you both, Fred & Marshall.

Marshall Barton said:
It sounds like you skipped Fred's second step about the
Current event.
--
Marsh
MVP [MS Access]


Ken said:
The checkbox fields now work to a point: When I toggle the "master yes/no"
checkbox the others will go gray/black as they should.

However, as I scroll through records, this conditional formatting is not
remembered. That is, I often come to a record where the master yes/no is
"no" but the other boxes are black, or master yes/no is "yes" but the others
are grayed out. It does not remember and automatically interpret the master
yes/no unless it is updated.

Is there a way for the format to be attached to another event that will keep
it each time I go to a new record AND update a current record?


On Fri, 23 Sep 2005 14:50:16 -0700, Ken Cobler wrote:
I have several checkboxes on a Form. The first checkbox is a general yes/no
choice. If the answer is "no" on this checkbox, I would like all the other
checkboxes to be grayed-out. If the answer is "yes", then the other detailed
checkboxes would be black and allow for further yes/no responses.

:
First, set the Enabled property of all the check boxes (except the
general one) to No.

Then code the AfterUpdate event of the first check box:

Me![CheckBox2].enabled = Me![CheckBox1]
Me![CheckBox3].enabled = Me![CheckBox1]
Me![CheckBox4].enabled = Me![CheckBox1]

Place the same code in the Form's Current event.
 
F

fredg

Great news!! It works!! Almost...I say that with a smile! Okay, the radio
buttons only allow you to choose one option and thats really what is needed.
The only thing left to do now is make the unchosen buttons turn gray when one
is selected. I know you may be thinking why? Its a boss thing, he's really
hung up on graying out all the rest!! Something he saw on a web site and
won't let go of! Any ideas? Thanks for all you help so far, I really
appreciate it!! Happy Holidays!!!
Myron

:
***** snipped ****

I have no idea whose or which message you are referring to,
mscertified or mine.

In any event, check boxes and radio buttons have an Enabled property,
which is what I have been posting about.
It changes the check box/radio color and one cannot enter it.
So if you have set it's enabled property to False, you cannot then
select it.

The last post (to reverse the enabled logic) was:
Me![CheckBox2].enabled = Not Me![CheckBox1]
etc.
Is that not what you are looking for?
 
G

Guest

Sorry about that Fred, I was talking to mscertified. I tried what you sent
in the on properties as you had explained in your other thread but I can't
get it to work. What I am trying to make happen is this...we train aviation
here for the Army. They can train several types of courses and this report
is the after action report input form for our commander. Looks like this:

o RL Prog
o Refresher
o MOB
o MOC

When the trainer selects one of these radio buttons the rest should go gray.
I got the wizzard to allow only one choice but want the remainder gray after
selection.

Do you think the code you sent is right and I just messed up putting it to
work? Please advise.
Thanks,
Myron



fredg said:
Great news!! It works!! Almost...I say that with a smile! Okay, the radio
buttons only allow you to choose one option and thats really what is needed.
The only thing left to do now is make the unchosen buttons turn gray when one
is selected. I know you may be thinking why? Its a boss thing, he's really
hung up on graying out all the rest!! Something he saw on a web site and
won't let go of! Any ideas? Thanks for all you help so far, I really
appreciate it!! Happy Holidays!!!
Myron

:
***** snipped ****

I have no idea whose or which message you are referring to,
mscertified or mine.

In any event, check boxes and radio buttons have an Enabled property,
which is what I have been posting about.
It changes the check box/radio color and one cannot enter it.
So if you have set it's enabled property to False, you cannot then
select it.

The last post (to reverse the enabled logic) was:
Me![CheckBox2].enabled = Not Me![CheckBox1]
etc.
Is that not what you are looking for?
 
F

fredg

Sorry about that Fred, I was talking to mscertified. I tried what you sent
in the on properties as you had explained in your other thread but I can't
get it to work. What I am trying to make happen is this...we train aviation
here for the Army. They can train several types of courses and this report
is the after action report input form for our commander. Looks like this:

o RL Prog
o Refresher
o MOB
o MOC

When the trainer selects one of these radio buttons the rest should go gray.
I got the wizzard to allow only one choice but want the remainder gray after
selection.

Do you think the code you sent is right and I just messed up putting it to
work? Please advise.
Thanks,
Myron

fredg said:
Great news!! It works!! Almost...I say that with a smile! Okay, the radio
buttons only allow you to choose one option and thats really what is needed.
The only thing left to do now is make the unchosen buttons turn gray when one
is selected. I know you may be thinking why? Its a boss thing, he's really
hung up on graying out all the rest!! Something he saw on a web site and
won't let go of! Any ideas? Thanks for all you help so far, I really
appreciate it!! Happy Holidays!!!
Myron

:
***** snipped ****

I have no idea whose or which message you are referring to,
mscertified or mine.

In any event, check boxes and radio buttons have an Enabled property,
which is what I have been posting about.
It changes the check box/radio color and one cannot enter it.
So if you have set it's enabled property to False, you cannot then
select it.

The last post (to reverse the enabled logic) was:
Me![CheckBox2].enabled = Not Me![CheckBox1]
etc.
Is that not what you are looking for?

If the above buttons are part of an OptionGroup, clicking any one
button within the group clears any of the other buttons so only one
button can be selected at a time. This permits corrections in the
event of a wrong entry.

I'm not clear on what you intend to accomplish, and precisely what you
mean by 'gray out'. By 'gray out' I'm assuming Not Enabled.

Do you want to prevent a change in an entry after it has been made.
You can code the AfterUpdate event of the OptionGroup:

Me![SomeOtherControl].SetFocus
Me!OptionGroupName.Enabled = False

This will make the control not editable for this record.

Change SomeOtherControl to the name of any control on your form.
Change OptionGroupName to the actual name of the option group.

You will also need to code the Form's current event, so that the
control is enabled again for the next record.

Assuming the option values are 1, 2, 3, etc. Code the Current event:
If Me!OptionGroupName > 0 Then
Me!OptionGroupName.Enabled = False
Else
Me!OptionGroupName.Enabled = True
End If

Once a value has been selected, the value will no longer be
changeable. The control will be available for the next record if no
value has yet been selected.

How are you going to handle the situation when an incorrect value has
been selected?
 
G

Guest

Fred,
Good point on what to do if the user makes a mistake. This whole thing is a
result of my boss's desire to see gray boxes. I explained to him this
morning how the option group only allows one and if he is still stuck on the
gray thing I will work on it but for now the basic requirement of only one
option has been met. I will put the thing you gave me to use and see how it
works out. Thanks a bunch for all you help and also a thanks to mscertified
as well!!

Happy Holdiays!
Myron

fredg said:
Sorry about that Fred, I was talking to mscertified. I tried what you sent
in the on properties as you had explained in your other thread but I can't
get it to work. What I am trying to make happen is this...we train aviation
here for the Army. They can train several types of courses and this report
is the after action report input form for our commander. Looks like this:

o RL Prog
o Refresher
o MOB
o MOC

When the trainer selects one of these radio buttons the rest should go gray.
I got the wizzard to allow only one choice but want the remainder gray after
selection.

Do you think the code you sent is right and I just messed up putting it to
work? Please advise.
Thanks,
Myron

fredg said:
On Tue, 6 Dec 2005 08:04:03 -0800, Myron Mummey wrote:

Great news!! It works!! Almost...I say that with a smile! Okay, the radio
buttons only allow you to choose one option and thats really what is needed.
The only thing left to do now is make the unchosen buttons turn gray when one
is selected. I know you may be thinking why? Its a boss thing, he's really
hung up on graying out all the rest!! Something he saw on a web site and
won't let go of! Any ideas? Thanks for all you help so far, I really
appreciate it!! Happy Holidays!!!
Myron

:

***** snipped ****

I have no idea whose or which message you are referring to,
mscertified or mine.

In any event, check boxes and radio buttons have an Enabled property,
which is what I have been posting about.
It changes the check box/radio color and one cannot enter it.
So if you have set it's enabled property to False, you cannot then
select it.

The last post (to reverse the enabled logic) was:
Me![CheckBox2].enabled = Not Me![CheckBox1]
etc.
Is that not what you are looking for?

If the above buttons are part of an OptionGroup, clicking any one
button within the group clears any of the other buttons so only one
button can be selected at a time. This permits corrections in the
event of a wrong entry.

I'm not clear on what you intend to accomplish, and precisely what you
mean by 'gray out'. By 'gray out' I'm assuming Not Enabled.

Do you want to prevent a change in an entry after it has been made.
You can code the AfterUpdate event of the OptionGroup:

Me![SomeOtherControl].SetFocus
Me!OptionGroupName.Enabled = False

This will make the control not editable for this record.

Change SomeOtherControl to the name of any control on your form.
Change OptionGroupName to the actual name of the option group.

You will also need to code the Form's current event, so that the
control is enabled again for the next record.

Assuming the option values are 1, 2, 3, etc. Code the Current event:
If Me!OptionGroupName > 0 Then
Me!OptionGroupName.Enabled = False
Else
Me!OptionGroupName.Enabled = True
End If

Once a value has been selected, the value will no longer be
changeable. The control will be available for the next record if no
value has yet been selected.

How are you going to handle the situation when an incorrect value has
been selected?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top