Results 1 to 3 of 3
  1. #1
    WS Lounge VIP
    Join Date
    Mar 2002
    Location
    Newcazzle, UK
    Posts
    2,832
    Thanks
    136
    Thanked 484 Times in 461 Posts
    Hi All

    I have a MultiPage control on a UserForm
    I have a number of textboxes on each Page, and these are named tbSize1, tbSize2, .., tbSize12, tbAmt1, tbAmt2, .., tbAmt12 etc.
    Is there a way of looping through these textboxes, say 1 to 12 on tab Page 1, using their textbox names?
    For example, if I have zValue = 7, I want to 'grey out', i.e. have textbox enabled set to False, for textboxes tbSize8 to tbSize12 and for textboxes tbAmt8 to tbAmt12.

    zeddy

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Zeddy,

    Here's some code you can adapt to your needs.
    Code:
    Private Sub obShowHide_Click()
    
        Dim iCntr  As Integer
        Dim btbSet As Boolean
        
        If obShowHide.Caption = "Hide" Then
          btbSet = False
          obShowHide.Caption = "Show"
        Else
          btbSet = True
          obShowHide.Caption = "Hide"
        End If
        
        For iCntr = 1 To 4
           Me.Controls("TextBox" & Format(iCntr)).Enabled = btbSet
        Next iCntr
         
        obShowHide = False
        
    End Sub
    Attached Images Attached Images
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    WS Lounge VIP
    Join Date
    Mar 2002
    Location
    Newcazzle, UK
    Posts
    2,832
    Thanks
    136
    Thanked 484 Times in 461 Posts
    Hi RetiredGeek

    Many thanks and a thumbs up from me.

    I was using Me.Textboxes(
    instead of
    Me.Controls(

    Problem solved.

    zeddy

Posting Permissions

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