Welcome to SPN

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

Sign Up Now!

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.
     

Share This Page