Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Feb 2001
    Location
    Vancouver, BC, Br. Columbia, Canada
    Posts
    96
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Setting checkboxes to true within a frame (Word 97)

    I have 20 or so checkboxes on a page of a multipage form and sitting inside a frame. Need to set them all the true at click of a button. I can cycle through all checkboxes on a form with following code, but just can't figure out how to cycle through JUST the checkboxes within the frame or on the page. I guess checking for the control name as starting with "chk" is not the prettiest way to go, but darned if I could find a way to check for a checkbox outright.

    Private Sub cmdSelectAll_Click()
    Dim ctrlCheck As Control

    For Each ctrlCheck In frmMain.Controls

    If pgMultiPage.Name = "pgOptions" And Mid(ctrlCheck.Name, 1, 3) = "chk" Then 'THIS NOT WORKING AS pgMultipage.name ALWAYS = pgmultipage!
    ctrlCheck.Value = True
    End If

    Next ctrlCheck
    End Sub

    <img src=/S/crybaby.gif border=0 alt=crybaby width=15 height=15>
    Gwenda

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Setting checkboxes to true within a frame (Word 97)

    Gwenda,

    You can use either 'TypeOf' or 'TypeName' - see the thread that follows <!post=this post,148266>this post<!/post> for syntax as well as some things to look out for.

    Gary

  3. #3
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Setting checkboxes to true within a frame (Word 97)

    Hi Gwenda,
    If the checkboxes are all inside a frame and there are no other controls within the frame, you should be able to just loop through the frame's controls collection and set each control to true. Should be a little quicker than looping through all the controls on the form.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •