Hi everybody,
[Access 2003]
I have a quality assurance database that has a form with a bunch of checkboxes on it that serve as reasons for why a product didn't pass inspection.
It's a given that the users will be able to select individual checkboxes to indicate the reasons. What I would like to find out how to do is to put a checkbox or radio button on the form that will select all the checkboxes if it's selected.
When I added a checkbox to my form and tried to write code for it, the control didn't have a 'Value' or 'Checked' property for me to choose. Is it not possible to do this? If I use a radio button, I'd like to have one to 'Select All' and one to 'Deselect' if at all possible.
I tried the following to no avail based on something I found online: -
Private Sub chkSelectAll_AfterUpdate()
-
me.chkDefect = me.chkSelectAll
-
me.chkPowerSupply = me.chkSelectAll
-
end sub
-
Can anyone share a little help with me?
Thanks in advance,
beacon
13 2553 -
me!chkDefect = me!chkSelectAll
-
me!chkPowerSupply = me!chkSelectAll
-
You do not need a 'Deselect' as all will be deselected if/when chkSelectAll is clicked again, and is then false.
It makes no difference whether you use checkboxes or radiobuttons. However, radiobuttons imply that only one can be true at any given time. Radio button refers to a radio presets, and selecting a station deselects another. I assume that a product can fail for multiple reasons simultaneously, and therefore checkboxes would be my preference.
OldBirdman
Hi OldBirdMan,
Here's the code I entered for my 'Select All' checkbox. I don't think it matters, but the checkboxes are all on a tab control. -
Private Sub chkSelectAll_AfterUpdate()
-
me.chkDefect = me.chkSelectAll
-
End Sub
-
When I enter this and go back to use the 'Select All' checkbox, I get an error message that says, "Run-time error 438: Object doesn't support this method or property."
This is the error message I was getting initially that prompted me to post to the forum. I don't use checkboxes that often and this is the first time I've tried to control other checkboxes with a checkbox.
NeoPa 32,569
Recognized Expert Moderator MVP
Hi OB. Good to see you around again :)
Assuming the clever naming structure that OB displays in his example (All CheckBox controls, and only CheckBox controls, start chk) and also that chkSelectAll & chkDeselectAll are the only ones ending in the last three characters "All", then the following code should help somewhat : - Private Sub chkSelectAll_AfterUpdate()
-
Call SetAll(blnValue:=True
-
End Sub
-
-
Private Sub chkDeselectAll_AfterUpdate()
-
Call SetAll(blnValue:=False
-
End Sub
-
-
Private Sub SetAll(blnValue As Boolean)
-
Dim ctlThis As Form.Control
-
-
For Each ctlThis In Me.Controls
-
If Left(ctlThis.Name, 3) = "chk" _
-
And Right(ctlThis.Name, 3) <> "All" Then _
-
ctlThis = blnValue
-
Next ctlThis
-
End Sub
NeoPa 32,569
Recognized Expert Moderator MVP @beacon
This is because the items you're dealing with are objects whose default property is .Value.
When mixed with other items (EG. Me.chkDefect = blnValue) it determines the default property to be required. When used object to object (as here) it thinks you want to assign one object to the other (EG. Set objVar = Me.chkSelectAll ).
Does that clarify your understanding?
FishVal 2,653
Recognized Expert Specialist @beacon
That only means Me object doesn't support either chkDefect or chkSelectAll property, most probably chkDefect.
@NeoPa
I understand what you're saying, but I'm not sure how to rectify the problem. I saw your response that showed how I could loop through each of the controls based on the 'chk' prefix, but it brings up another potential issue I'll undoubtedly run into.
The potential issue is how can I handle this problem if I'm asked to put in another checkbox that allows the user to select default reasons. For instance, we have 'Select All' that chooses all of the checkboxes and we have a 'Select Default' that only chooses a certain selection based on the product type...how can I indicate just a select few to be selected when that option is chosen?
Keep in mind that there are multiple different products so the options will be different for 'Select Default' based on the product.
No, it doesn't clear up anything. It seems like I assign .value to .value all the time. txtA = txtB, chkC = chkD, or txtE = cboF, etc. Never had any issues here with Access making the assignments. Because this code is in the form's module, can't the "me" be dropped completely?
Clever naming structure belongs to beacon's original post, I kept answers in his framework, but it is similar to my naming conventions.
As to having a "DeSelectAl l" checkbox, the code shown does not clear it when "SelectAll" is checked. Reflecting on this, I don't think there should be either a Select or DeSelect checkbox. They should be command buttons, "Select All" and "Clear All".
If a product is defective in all categories except 1, user might want to select all, and then deselect it (i.e. uncheck chkPowerSupply) to show that it passed the one test. The chkSelectAll is now incorrect if it means that all checkboxes are checked. It gets more complicated because, after each individual checkbox is changed, all must be checked to see if either chkSelectAll or chkDeSelectAll should be changed. chkSelectAll = (chkPowerSupply And chkDefect . . .) and DeSelectAll = Not (chkPowerSupply Or chkDefect Or . . .). This could be done in a loop similar to that shown in Post #4 by NeoPa.
This could be expanded to include a "Default" command button. (This discussion is now about sets of checkboxes, not the actual problem presented, as something is very wrong if there is a "Default" set of flaws in a product. Improve your quality control, or get a new supplier). Each item would have a Default set of flaws.
Checkboxes would have to be TripleState, and locked if grayed, or Checkboxes would vary from item to item. You might consider a subform with each record showing an inspection item and a checkbox. This is a database design issue.
OldBirdman
I think I found my answer on this website: ** Edit ** link removed.
In case you don't want to go to the website, the gist of the solution is to enter a tag for each of the checkboxes I want selected (All or default) and then create an AfterUpdate() event for the checkbox that will trigger the event.
Here's the code assuming that I put a tag of 'SelectAll' or 'Default' in for the checkboxes that I want controlled by the chkSelectAll or chkDefault: -
Private Sub chkSelectAll_AfterUpdate()
-
Dim ctl as Control
-
-
For Each ctl In Me.Controls
-
If Me.chkSelectAll = True Then
-
If ctl.Tag = "SelectAll" Then
-
ctl.Value = True
-
End If
-
Else
-
If ctl.Tag = "SelectAll" Then
-
ctl.Value = False
-
End If
-
End If
-
Next ctl
-
End Sub
-
This will check only the boxes that you've entered a tag for. I took the code I found and took it one step further by adding the conditional "If Me.chkSelectAll = True" around the other conditional "If ctl.Tag = 'SelectAll'..." which allows you to deselect your selection.
I don't really understand how I was able to give a ctl a .Value when it wasn't available from the properties when I typed in the code, but it works. I know that you can't just type the following: -
If ctl.Tag = "SelectAll" Then
-
ctl.Value = True
-
Else
-
ctl.Value = False
-
End If
-
...because it will give you an error message similar to the runtime error 438 I was receiving when I initially began this process.
You have to put in some work to add the tags to each of the checkboxes, but once you get that entered it works pretty well.
Thanks for everybody's input...
NeoPa 32,569
Recognized Expert Moderator MVP @beacon
As it seems you have already discovered, a good way to track this when the conditions are not as simple as those stipulated, is to use the Tag property of a control. Any value could be used for the tag simply to identify which are grouped together : - Private Sub SetAll(blnValue As Boolean)
-
Dim ctl As Form.Control
-
-
For Each ctl In Me.Controls
-
If ctl.Tag = "Group1" Then ctl = blnValue
-
Next ctl
-
End Sub
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: newjazzharmony |
last post by:
Hello group,
I want to automatically select a specific checkbox when a user clicks
(selects) a specific item in a radiobutton group. Both controls are in
the same form.
Let's say for argument's sake that the form looks like this
(inessential items left out for the sake of clarity):
<form name=form1>
|
by: delram |
last post by:
I'm trying to get user selections (using checkboxes) on one JSP page(A.jsp) and pass them on to another page.
So I have one page with a list of dynamically populated items like this
1
2
...
...
n
|
by: uremog |
last post by:
I have a set of of check boxes. onClick, the checkboxes call check_radio and recup_checkbox. the referenced radios function as group selectors. check_radio just unchecks the radios if someone manually selects checkboxes.
i think the problem is in the add_selection and del_selection as suggested by the alerts, which are for debugging only. it gets as far as the alert(add/del selection) alerts in FF. all the alert tests pass in IE.
as...
|
by: =?Utf-8?B?UmljaA==?= |
last post by:
Is there a cancel argument for cancelling if you want to check or uncheck a
checkbox?
In the checkChanged event of a checkbox I ask the user if they are sure they
want to check/uncheck something. If No, I want to cancel the check or
uncheck and cancel the click event. Right now I have a form level boolean
checkvar that I set based on the user's response. If No then when entering
the click event I don't perform various actions. Is...
|
by: dkultasev |
last post by:
Hello,
I have small script which generates some listboxes. Their names are
listXX (list01, list02, list03....). How to check if there are checked
or not ? If I have 1 listbox and have it's name I do $_POST.
But what to do in that situation ?
Sincerely,
Dmitrij
| |
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |