UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Check Boxes On A Access Form Vb    
 
   
Comicwizard
post Feb 27 2012, 12:12 PM
Post #1

UtterAccess Enthusiast
Posts: 69



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.

Go to the top of the page
 
+
theDBguy
post Feb 27 2012, 12:20 PM
Post #2

Access Wiki and Forums Moderator
Posts: 48,633
From: SoCal, USA



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... (IMG:style_emoticons/default/2cents.gif)
Go to the top of the page
 
+
Comicwizard
post Feb 27 2012, 12:35 PM
Post #3

UtterAccess Enthusiast
Posts: 69



access 2007
Go to the top of the page
 
+
Comicwizard
post Feb 28 2012, 01:51 PM
Post #4

UtterAccess Enthusiast
Posts: 69



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.
Go to the top of the page
 
+
Comicwizard
post Mar 1 2012, 04:40 PM
Post #5

UtterAccess Enthusiast
Posts: 69



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
Go to the top of the page
 
+
theDBguy
post Mar 1 2012, 05:26 PM
Post #6

Access Wiki and Forums Moderator
Posts: 48,633
From: SoCal, USA



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... (IMG:style_emoticons/default/2cents.gif)


(Note to self: 35K post)

This post has been edited by theDBguy: Mar 1 2012, 06:06 PM
Go to the top of the page
 
+
Comicwizard
post Mar 2 2012, 11:00 AM
Post #7

UtterAccess Enthusiast
Posts: 69



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 :-)
Attached File(s)
Attached File  CCL_Test.zip ( 22.68K ) Number of downloads: 1
 
Go to the top of the page
 
+
theDBguy
post Mar 2 2012, 11:53 AM
Post #8

Access Wiki and Forums Moderator
Posts: 48,633
From: SoCal, USA



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... (IMG:style_emoticons/default/2cents.gif)
Attached File(s)
Attached File  CCL_Test.zip ( 19.56K ) Number of downloads: 4
 
Go to the top of the page
 
+
Comicwizard
post Mar 2 2012, 11:55 AM
Post #9

UtterAccess Enthusiast
Posts: 69



I just need a trigger to either enable = false or enable = true in the code. I will look at what was provided. Thank you
Go to the top of the page
 
+
theDBguy
post Mar 2 2012, 11:57 AM
Post #10

Access Wiki and Forums Moderator
Posts: 48,633
From: SoCal, USA



Hi,

QUOTE (Comicwizard @ Mar 2 2012, 09:55 AM) *
I just need a trigger to either enable = false or enable = true in the code. I will look at what was provided. Thank you

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? (IMG:style_emoticons/default/iconfused.gif)

Just my 2 cents... (IMG:style_emoticons/default/2cents.gif)
Go to the top of the page
 
+
Comicwizard
post Mar 2 2012, 12:04 PM
Post #11

UtterAccess Enthusiast
Posts: 69



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?
Go to the top of the page
 
+
theDBguy
post Mar 2 2012, 12:12 PM
Post #12

Access Wiki and Forums Moderator
Posts: 48,633
From: SoCal, USA



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... (IMG:style_emoticons/default/2cents.gif)
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th June 2013 - 03:17 PM