Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checkbox values

Status
Not open for further replies.

supernewb

Technical User
Feb 7, 2005
18
US
hi all,
i'm trying to look through a group of checkboxes to see if any of them have been checked. if ANY have been checked then i would like to make the value of the CheckBox_p2b true.

word2000 document

p2b (controls the subtitle on the document)
p2b1 (bullet point1 on doc)
p2b2 (bullet point2 on doc)
etc.

Code:
Dim a As Long
a = 1
    If me.Controls("CheckBox_p2b" & a).Value = True Then
     Do Until a = 26
     CheckBox_p2b.Value = True
     a = a + 1
 Loop
End If

this only works if the first item under p2b (p2b1) is selected on the form. i'm sure there is a better way to do this.

thanks!
 

hi,

You have your if..end if in the wrong place
Code:
    For Each ctr In Me.Controls
        With ctr
            If .Name <> "CheckBox_p2b" Then
                If Left(.Name, 12) = "CheckBox_p2b" Then
                    If .Value Then
                        CheckBox_p2b.Value = True
                        Exit For
                    End If
                End If
            End If
        End With
    Next

Skip,

[glasses] [red]Be advised:[/red] When you ignite a firecracker in a bowl of vanilla, chocolate & strawberry ice cream, you get...
Neopolitan Blownapart! [tongue]


 
For a = 1 To 26
If Me.Controls("CheckBox_p2b" & a).Value = True Then
CheckBox_p2b.Value = True
Exit For
End If
Next a

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
they work!!! thanks so much Skip(again) and PH. i'd been struggling with that loop for days.

dina
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top