Full Version: Check Boxes On A Access Form Vb
UtterAccess Discussion Forums > Microsoft® Access > Access Reports
Comicwizard
Hi, I have a form that has nine check boxes.

What I need to happen is that if I choose boxes #1 through #8 in any combination, one or all, the ninth box deactivates and prevents you from checking that ninth box.

In the reverse if I check the ninth box all the others become deactive.

Activating and deactivating a single box in VB is easy, but I am having troubles writing code to make any combination of the other boxes deactivate the ninth box.
theDBguy
Hi,

What version of Access are you using? Knowing the Access version may help us determine a more appropriate response to your question.

In the AfterUpdate event of your ninth checkbox, you could try something like:

If Me.Check9 Then
Me.Check1.Enabled = False
Me.Check2.Enabled = False
... and so on...
Else
Me.Check1.Enabled = True
... and so on...
End If

In the AfterUpdate event of each of the other eight checkbox, you could try something like:

If Me.Check1 Then
Me.Check9.Enabled = False
ElseIf Me.Check2+Me.Check3...+Me.Check8 = 0 Then
Me.Check9.Enabled = True
End If

Just my 2 cents... 2cents.gif
Comicwizard
access 2007
Comicwizard
that almost works, I had something similar to that but I had defined each checkbox results as:

if me.checkbox1=true then
me.checkbox9.enabled = false


So I rewrote my code to match your example and it still triggers the 9th checkbox

as an example....

If check more than one box, then uncheck one box, but still have another checked the 9th box reactivates.

so I have to figure the code so if I check or uncheck any of the first 8 check boxes the 9th box stays inactive.
Comicwizard
okay I think I have figured out what is happening.

The form is tied to a table. When the check boxes are checked the form isn't refocusing/saving how ever you say it, until you move on to another record.
Each check box is it's own individual field on the table. until you leave, the code will not make any changes.

So here is a set of questions:

Do I need to set the check box default value to be zero to start with?
Do I need to add saverecord to the code so the value of the check box is added to the table for the code to work?

Should those fields be a text value or a numeric value? Why I ask this I have a report process which takes all numeric values and replaces them with words from a response table. so if I need to have the check boxes as numeric values I can just add another field that is text to provide the words.

I can post pictures or a sample database if that would help
theDBguy
Hi,

Posting a sample database is preferred. Make sure you remove any sensitive data then do a C&R. Compress the file and then upload the zip file.

Just my 2 cents... 2cents.gif


(Note to self: 35K post)
Comicwizard
What I did was made a test database with the check boxes and created a table with fake data I am up loading it here. For those who just joined this issue.

I have a form connected to a table with data. There are 9 check boxes. When someone checks any of 1-8 boxes the 9th box should deactive. if someone checks 9 the first 8 deactivates.

When boxes 1-8 are checked the comment field on the table should auto fill "Completed"
when box 9 is checked the table comment field should say "Not completed"

I have tried if else then
I have played with case statements

The trouble I am having is the check boxes start off unactivated until they are checked. so those fields on the table I am thinking start off NULL, once checked they have a value of -1, unchecked they become 0.

Unless you check and uncheck all boxes you will not have any values in those fields.

maybe having the check boxes defaulted to unchecked to begin with?

thanks everyone for the help :-)
theDBguy
Hi,

Check out the attached modified version of your db. I just changed the values in the checkboxes because I am not really sure where you want to go with "disabling" them.

Just my 2 cents... 2cents.gif
Comicwizard
I just need a trigger to either enable = false or enable = true in the code. I will look at what was provided. Thank you
theDBguy
Hi,

The "funny" thing about disabling controls is this: If you disable Check9 when the user clicks on the other checkboxes, how will they be able to check Check9 again if they want or need to? In the same token, if you disable all the other checkboxes when they click on Check9, how will they be able to click on the other checkboxes again to complete the record? iconfused.gif

Just my 2 cents... 2cents.gif
Comicwizard
ah,

What is suppose to happen is when 1-8 is checked, 9 becomes unavailable to be checked. then when 1-8 is unchecked, 9 becomes available again, and the opposite, when I uncheck 9 the other boxes become available again.

The reason is to prevent all from being checked.

either I have 1-8 which means something has been completed.

or 9 which means none of the other 8 things have been completed.

I do not want to have all 1-8 meaning completed and then checking 9 which would provide conflicting response. either things were done or not. not both.

sorry for the confusion, does this clear things up?
theDBguy
Hi,

Yes, that makes more sense now... However, without doing the "diabling" feature, check out the demo I posted because it will not let you check all checkboxes at the same time, and it provides the correct comment in the textbox as well.

Just my 2 cents... 2cents.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.