Checkboxes (1 Viewer)

BadScript

Registered User.
Local time
Today, 02:18
Joined
Oct 30, 2007
Messages
73
In my form I have 30 checkboxes named chk1 to chk30, whenever I check one of these checkboxes I would like chk_reject to be checked as well. Is there a way to do this without editing the afterupdate of 30 checkboxes?
 

neileg

AWF VIP
Local time
Today, 10:18
Joined
Dec 4, 2002
Messages
5,975
If you want this to update as soon as you check another box then you have to use the after update event of the individual boxes. If you can use another event then you can simply add up the values of the combos (unchecked is 0 and checked is -1) and if it isn't 0 then one or more of the boxes is checked.
 
Last edited:

BadScript

Registered User.
Local time
Today, 02:18
Joined
Oct 30, 2007
Messages
73
Thanks, I'm very new to this VB stuff but I think I'll be able to figure it out then :D
 

BadScript

Registered User.
Local time
Today, 02:18
Joined
Oct 30, 2007
Messages
73
Figured it out so might as wel post it in here for people that are looking for the same thing..
In the afterupdate event of the checkboxes insert:

If Me.chk1 = -1 Then chk_reject = True
 

neileg

AWF VIP
Local time
Today, 10:18
Joined
Dec 4, 2002
Messages
5,975
It's a bit easier to follow if you stick to the same convention for the value, so

If Me.chk1 = True Then chk_reject = True
 

BadScript

Registered User.
Local time
Today, 02:18
Joined
Oct 30, 2007
Messages
73
Thanks alot...

Btw, the other way around is gonna be even worse:
Would like to uncheck chk_reject when all 30 boxes are unchecked and came up with this in the afterupdate of chk1 to chk30:

If chk1 = False And chk2 = False And chk3 = False And chk4 = False And chk5 = False And chk6 = False And chk7 = False And chk8 = False And chk9 = False And chk10 = False Then chk_reject = False

are you sure there isn't an easier way.. have to do this for 30 checkboxes x 30... :eek:

is there a way to say: if chk1 to chk30 = false then chk_reject = false?
 
Last edited:

neileg

AWF VIP
Local time
Today, 10:18
Joined
Dec 4, 2002
Messages
5,975
You only have to type it once and copy and paste the text into the other check boxes.
 

BadScript

Registered User.
Local time
Today, 02:18
Joined
Oct 30, 2007
Messages
73
I did, but now I want to make it where I can erase chk1 to chk30 when I manually uncheck chk_rejected.

I mean I can do this with If me.chk_rejected = False Then chk1 = False And chk2 = false etc..

It will work and I will do this in the mean time but it might be bit sloppy (?)
Really want to learn this stuff so I'm open to all suggestions :)
 

BadScript

Registered User.
Local time
Today, 02:18
Joined
Oct 30, 2007
Messages
73
little mistake.. solved it like:

If Me.chk_reject = False Then DoCmd.Requery "chk1"
[chk1] = False
If Me.chk_reject = False Then DoCmd.Requery "chk2"
[chk2] = False

etc..
 

neileg

AWF VIP
Local time
Today, 10:18
Joined
Dec 4, 2002
Messages
5,975
I think your table design may be poor and this is giving you the headache. I assume you have 30 tests that you want to apply and if any one of these tests fail then the item as a whole fails.

Instead of 30 checkboxes (what happens if you need to add a 31st test?) I would have a related table and only store results of failed tests. Then you can count the number of entries in this table and if it's zero it's a pass, if it's greater than zero it's a fail.

See the attached.
 

Attachments

  • db4.zip
    22.4 KB · Views: 96

BadScript

Registered User.
Local time
Today, 02:18
Joined
Oct 30, 2007
Messages
73
You are absolutely right..

I will have a look at it tonight, thanks..

Have been thinking to add a table for those questions/checkboxes but as this is just a very basic version that I have in mind and my time is rather limited I didn't yet. I don't even know the questions yet so can't really think of how I will implement. I got it all working though, although I'm trying to figure out how to disable a certain checkbox when another is checked...
I'm trying to convince my boss that he should supply me with visual studio..

There's still so much I got to figure out and the problem with access is that the learning material for access is either too basic or mind boggling difficult..
So until i find a good book that is on the right level I am trying to tie the knots together from scripts on this forum and examples I find on the Internet..
 
Last edited:

BadScript

Registered User.
Local time
Today, 02:18
Joined
Oct 30, 2007
Messages
73
I think your table design may be poor and this is giving you the headache. I assume you have 30 tests that you want to apply and if any one of these tests fail then the item as a whole fails.

Instead of 30 checkboxes (what happens if you need to add a 31st test?) I would have a related table and only store results of failed tests. Then you can count the number of entries in this table and if it's zero it's a pass, if it's greater than zero it's a fail.

See the attached.
That's pretty good but mine works a bit different, I have a negative checklist and when an item is not correct they can tick the reason. When one of the boxes is ticked I want my accept checkbox to disappear and the reject checkbox checked. When I uncheck the reject button I want my 30 checkboxes cleared and my accept checkbox visible again..
Have no idea how I will do that based on a table at this point, but maybe it's worth to figure it out..
I have it all working now but like you said it's not very flexible..
 
Last edited:

Users who are viewing this thread

Top Bottom