Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

Check uncheck all checkboxes

Discussion in 'Information Technology' started by VB, Nov 7, 2005.

  1. VB

    VB
    Expand Collapse
    Guest

    please, help me to create checkbox on the for that will check/uncheck 20
    other checkboxes on the same form.
     
  2. Loading...


  3. Douglas J. Steele

    Douglas J. Steele
    Expand Collapse
    Guest

    Won't it make more sense to use a button, not another checkbox?

    Assuming you're going to uncheck every checkbox on the form, you need code
    like:

    Dim ctlCurr As Control

    For Each ctlCurr In Me.Controls
    If TypeOf ctlCurr Is Checkbox Then
    ctlCurr = False
    End If
    Next ctlCurr

    If you ARE going to use a checkbox to kick this off, you'll probably want to
    not uncheck the "trigger" checkbox, so you'd have something like:

    Dim ctlCurr As Control

    For Each ctlCurr In Me.Controls
    If TypeOf ctlCurr Is Checkbox Then
    If ctlCurr.Name <> "chkUncheckAll" Then
    ctlCurr = False
    End If
    End If
    Next ctlCurr

    If there are other checkboxes you don't want to impact, you'll need to come
    up with some other way of identifying those checkboxes that you do want to
    clear. One approach is to set the Tag property of those that you want to be
    able to clear. Put something like "Clear" in that property, and use code
    like:

    Dim ctlCurr As Control

    For Each ctlCurr In Me.Controls
    If TypeOf ctlCurr Is Checkbox Then
    If ctlCurr.Tag = "Clear" Then
    ctlCurr = False
    End If
    End If
    Next ctlCurr

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no e-mails, please!)



    "VB" <VB@discussions.microsoft.com> wrote in message
    news:B9031041-11D5-44EF-86AC-445C5D6228F5@microsoft.com...
    > please, help me to create checkbox on the for that will check/uncheck 20
    > other checkboxes on the same form.
     
  4. Ken Sheridan

    Ken Sheridan
    Expand Collapse
    Guest

    Put the following in the first check box's AfterUpdate event procedure:

    Dim ctrl As Control

    For Each ctrl In Me.Controls
    If ctrl.ControlType = acCheckBox Then
    ctrl = Me.ActiveControl
    End If
    Next ctrl

    "VB" wrote:

    > please, help me to create checkbox on the for that will check/uncheck 20
    > other checkboxes on the same form.
     
  5. VB

    VB
    Expand Collapse
    Guest

    works perfectly, thanks

    "Ken Sheridan" wrote:

    > Put the following in the first check box's AfterUpdate event procedure:
    >
    > Dim ctrl As Control
    >
    > For Each ctrl In Me.Controls
    > If ctrl.ControlType = acCheckBox Then
    > ctrl = Me.ActiveControl
    > End If
    > Next ctrl
    >
    > "VB" wrote:
    >
    > > please, help me to create checkbox on the for that will check/uncheck 20
    > > other checkboxes on the same form.
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page