Automatic Checkbox Problem

AnnPhil

Registered User.
Local time
Today, 22:42
Joined
Dec 18, 2001
Messages
246
Not sure what to call this

I have a (Check List) form that has several yes/no fields. I need another yes/no field to automate to yes when all the other yes/no fields have been checked yes. Not sure how to go about this. Any suggestions?
 
Hi,

Example :

Check3 is the check box that will trigger the other check boxes.
check0 , check1 , check2 are you single check boxes that you want triggering.

Put the following code on the onclick event of check3

me.check0 = checked
me.check1 = checked
me.check2 = checked
If me.check3 = unchecked Then
me.check0 = unchecked
me.check1 = unchecked
me.check2 = unchecked
End If

PS. This will certainly check the boxes from a trigger, but not sure if it will automatically store the values in the table, the code might need alterating slightly, maybe??


Hope this helps

Andy
 
Last edited:
Let's assume chkAll is the check box that will check all the checkboxes on the form:
Code:
Private Sub chkAll_Click()
Dim ctl As Control

    For Each ctl In Me
        If ctl.ControlType = acCheckBox Then
            ctl = Me.chkAll
        End If
    Next ctl
    
End Sub
Andy, the checked values will be stored in the underlying table IF the checkboxes are bound controls.
 
Actually what i need to happen is the opposite. When all the check boxes are checked then need another check box (check8) to check yes when all boxes are filled in. I figure an If statement but i dont know how to write one with multiple conditions.

If [check0] = True Then
If [check1] = True Then
If [check2] = True Then
If [check3] = True Then
If [check4] = True Then
If [check5] = True Then
If [check6] = True Then
If [check7] = True Then
Me.check8 = True
Else: check8 = False

End If
 
You mean you just want some type of indication that all other check boxes have been checked? I wouldn't use a check box for that, since it's usually a control that users have control over.

I would have some other indicator, like text in bold that says "All checked" or text in red that says "Not all checked".
 
You can try something similar to this:
Code:
Function CheckCheckBoxes()
Dim ctl As Control

    Me.txtStatus = "All checked"
    
    For Each ctl In Me
        If ctl.ControlType = acCheckBox Then
            If IsNull(ctl) Or ctl = False Then
                Me.txtStatus = "Not all checked"
                Exit Function
            End If
        End If
    Next ctl
    
End Function
It assumes that you have a text control called "txtStatus". It cycles through the check boxes on your form and see if they are all checked. If any are Null or not checked, it will write "Not all checked" into the txtStatus control.

Edit: Oh - you'll need to know where to put this code. You'll want to put:
=CheckCheckBoxes()
into the After Update event of all the checkboxes on your form.
 
thanks for your help dcx693 but i guess i am not very good at building functions and reference them in event cause i get an error message when i tried what you suggested.

the error message i get is Comple error: Expected: line number or label or statement or end of statement.

not sure what is wrong, i created the function and then put the =CheckCheckBoxes() in the Update event of the checkboxes and i got that error message.

If it is not to much trouble can you give me an idea what is wrong.

thanks
 
I am not too hot on functions but I have adapted the function that dcx693 to a form. Not ideal but it works.

See the attachment

Andy
 

Attachments

I forgot to mention that there are other check boxes in this form that i do not what to be evaluated. So this doesn't work for my form. Is there a way to use this code but reference only those 5 checkboxes? Sorry to be such a pain but i am learning!
Any help would be greatly appreciated. thanks
 
why not use checkboxes for the five you require and option buttons for the rest. This way you can use the current code.

If not post a db with the form so I can visualise your problem.

Regards

Andy
 
I dont think i want to use option buttons for the other fields but maybe if you took alook at the form you could give me another suggestion.

The area you want to look at is the Course Packet group. Then the other field is called Course Packet completed. that is the field i would like to automate yes if all items in the Course Packet group is checked yes.

The Course Packet completed field is used in a weekly report.

thanks for your help.
 
OK i figured something out that works but i would like to know how to do this by creating a public function and then call that function instead of writing the code below on each controls' AfterUpdate Event.

Private Sub Markers_AfterUpdate()
If [Registration Forms] And [InstructorPymt] And [Pencils] And [Markers] And [Evaluations] And [Name Tents] And [Books or material] And [Signin_GA Sheet] = -1 Then
[PK] = -1
Else
[PK] = 0

End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom