Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Count Checkboxes which are ticked in a form/table/Column

Posted on 2003-03-23
Medium Priority
Last Modified: 2008-03-06
I want to count all the checkboxes in a column which have been ticked.
I'v created a form, where the user will tick the checkbox, and then move on to the next record, now i want to get the total of the ticked checkboxes and display it on a form.
Question by:comicjoker
  • 3
  • 2
LVL 44

Expert Comment

ID: 8193364
Hello Comicjoker,

is this excel? since you mention column i presume the boxes are on a sheet? then this could help

Sub CountCheckedCheckboxes()
  Dim ws As Worksheet
  Dim objOLE As OLEObject
  Dim nNumChecks As Integer

  For Each ws In ThisWorkbook.Worksheets
    For Each objOLE In ws.OLEObjects
      If TypeName(objOLE.Object) = "CheckBox" Then
        If objOLE.Object.Value Then nNumChecks = nNumChecks + 1
      End If
    Next objOLE
  Next ws
  MsgBox nNumChecks
End Sub


Author Comment

ID: 8193373
Its in Access, sorry I forgot to mention it.
LVL 44

Accepted Solution

bruintje earned 600 total points
ID: 8193385
then you could try a little count function like this

Public Function CheckCount(frm as Form) AS Integer
     dim ctl as control
    dim cc as integer

    for each ctl in frm.controls
        if typeof ctl is checkbox then cc=cc+1

End Function

place it in a module and call it when you need to display it on a label on your form

Author Comment

ID: 8194433
What I did, was create a Query, with all the check boxes marked true. Then created a form based on the query, placed an edit box and in the control source typed ( =Count(*) ) which basicaly counts all the records in the query
LVL 44

Expert Comment

ID: 8196308
:) that's a solution too ... thanks for the grade

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an article on how to answer questions, earn points and become an expert.
With its various features, Office 365 can not only help you with your day-to-day business tasks, it can also do wonders for your marketing campaign.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question