473,395 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

One checkbox fills other checkboxes

114 100+
I've seen similar posts to what I am looking for but have not been able to successfully use what I have read.
I have a form with 4 checkboxes:
Expand|Select|Wrap|Line Numbers
  1. CkQ1
  2. CkJan
  3. CkFeb
  4. CkMar
I would like to be able to select CkQ1, and in doing so, Access would select the other three checkboxes (sort of an "all of the above" option). These checkboxes are not in an option group because multiple boxes could be selected (eg a user might only select CkJan and CkFeb). I am using Access 2003 on XP. I have attached a snapshot of the form in case that helps.

Is this sort of checkbox "filling" possible, especially for a user with limited vba knowledge (me). Thanks for any help!
martin
Attached Files
File Type: pdf Checkbox Look.pdf (4.4 KB, 319 views)
Oct 23 '07 #1
9 2901
lee123
556 512MB
you coulkd do an if statement like this

Expand|Select|Wrap|Line Numbers
  1. if ckq1 = true then
  2.    ckjan=true
  3.    ckfeb=true
  4.    ckmar= true
  5. else
  6.    ckq1=false
  7. end if
lee123
Oct 23 '07 #2
martin DH
114 100+
Thanks, I was sure it could be done simply through an If statement. Now some follow-up questions:

I altered the code using ElseIf statements to uncheck the three month checkboxes when the CkQ1 was unchecked. My code now looks like:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CkQ1_Click()
  2. If CkQ1 = True Then
  3.    CkJan = True
  4.    CkFeb = True
  5.    CkMar = True
  6. ElseIf CkQ1 = False Then
  7.    CkJan = False
  8.    CkFeb = False
  9.    CkMar = False
  10. End If
  11. End Sub
Question: After checking CkQ1, the other three checkboxes check. Now if I uncheck some of those other three boxes (eg I uncheck CkJan), I would like the CkQ1 to uncheck as well. I think that this is getting a little more complicated - but maybe only to me! Thank you for your help.

martin
Oct 24 '07 #3
NeoPa
32,556 Expert Mod 16PB
Let's clarify a little.
What do you want CkQ1 to be if chkJan is set but the others are cleared?

BTW To replace what you currently have try :
Expand|Select|Wrap|Line Numbers
  1. Private Sub CkQ1_AfterUpdate()
  2.   With Me
  3.     .CkJan = .CkQ1
  4.     .CkFeb = .CkQ1
  5.     .CkMar = .CkQ1
  6.   End With
  7. End Sub
Oct 24 '07 #4
martin DH
114 100+
Let's clarify a little.
What do you want CkQ1 to be if chkJan is set but the others are cleared?
Clarification is good. CkQ1 should ONLY be set if the user sets it specifically (another option if possible and not too difficult: CkQ1 could also be set if the three month checkboxes are all also set...).

If CkJan is set but the other two month checkboxes are cleared, CkQ1 should also be cleared.
Hope that helps!

Also, as I novice I don't know these things, why is the code you supplied a better choice than what I posted above. Thanks!

martin
Oct 24 '07 #5
NeoPa
32,556 Expert Mod 16PB
Thanks for the clarification.
I would say that code of the form :
Expand|Select|Wrap|Line Numbers
  1. B = A
is better (more succinct & readable) than :
Expand|Select|Wrap|Line Numbers
  1. If A = True Then
  2.   B = True
  3. Else
  4.   B = False
  5. EndIf
The Me. stuff (With Me etc) is just making the code more explicit. It is usually used when referring to controls on a form even though it's not, strictly speaking, necessary.
Oct 24 '07 #6
martin DH
114 100+
Thanks NeoPa, that makes perfect sense. KISS methodology is great.

Do you know how I can clear CkQ1 if any of the three subsequent checkboxes are cleared (eg if all three month checkboxes are set but then CkJan is cleared, CkQ1 should also clear). Thank you!

Martin
Oct 24 '07 #7
NeoPa
32,556 Expert Mod 16PB
Sure Martin.
Try something like :
Expand|Select|Wrap|Line Numbers
  1. Private Sub CkQ1_AfterUpdate()
  2.   With Me
  3.     .CkJan = .CkQ1
  4.     .CkFeb = .CkQ1
  5.     .CkMar = .CkQ1
  6.   End With
  7. End Sub
  8.  
  9. Private Sub CkJan_AfterUpdate()
  10.   Call UpdateCkQ1()
  11. End Sub
  12.  
  13. Private Sub CkFeb_AfterUpdate()
  14.   Call UpdateCkQ1()
  15. End Sub
  16.  
  17. Private Sub CkMar_AfterUpdate()
  18.   Call UpdateCkQ1()
  19. End Sub
  20.  
  21. Private Sub UpdateCkQ1()
  22.   With Me
  23.     .CkQ1 = (.CkJan And .CkFeb And .CkMar)
  24.   End With
  25. End Sub
This may not be exactly what you want as it also sets .CkQ1 if they are all individually set.
Oct 25 '07 #8
martin DH
114 100+
NeoPa,
Thank you very much. That is actually exactly what I was looking for. I appreciate your guidance!
martin
Oct 25 '07 #9
NeoPa
32,556 Expert Mod 16PB
No problem Martin :)
Glad you liked it.
Oct 25 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: feanor | last post by:
I need to select children checkboxes when selecting the parent one. This is my function: function SelectChildrens(checkbox_name){ form = document.forms; Sname = checkbox_name.split("-"); for...
34
by: clinttoris | last post by:
Hello Experts, I have been told to post this in the Javascript forum as I want to do this client side just before my form gets submitted. Once the user clicks the submit button a javascript...
6
by: Chuck Anderson | last post by:
My knowledge of JavaScript is limited. I learn from example and then adapt those examples to suit my needs. I have stumped myself on this one. I have a form with checkboxes that I want to...
29
by: Amer Neely | last post by:
I've got a dynamically built form with checkboxes for each element ( a list of file names in a directory). I need to grab only those checkboxes that are checked, so I can then delete those files. ...
10
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
0
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me...
10
by: LionsDome | last post by:
Hello, I have a vb.net page which a bunch of checkboxes. A user can select a checkbox(s) and hit the submit button to store those values in a SQL Server table. This works fine with no problem...
0
by: TechnoAtif | last post by:
<?php include "dbconnect.php"; include "commonFunc.php"; ?> <!----------------------------------> <table width="80%" border="1" cellpadding="2" cellspacing="0"> <tr > <td...
1
Death Slaught
by: Death Slaught | last post by:
I play a game that when your backpack fills with items (the limit is 45) you must choose items to discard by unchecking their box. This is very annoying and time consuming so I was wondering if it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.