Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2005
    Posts
    196

    Unanswered: Enable all text boxes - more foolproof method?

    Hi,

    I have written the following code:

    Code:
    Dim c As Control
        
            For Each c In Form
                If left(c.Name, 3) = "txt" Then
                    c.Enabled = True
                    c.Locked = False
                End If
            Next
    Obviously this works fine providing all text boxes follow the naming convention of a txt prefix. Is there a better way of doing it - i.e a way of testing that the control is a textbox rather than assuming from the name?

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    Dim Ctl As Control
    
    For Each Ctl In Me.Controls
    If Me(Ctl).ControlType = acTextBox Then
     Me(Ctl).Enabled = True
     Me(Ctl).Locked = False
    End If
    Next
    I learnt about .ControlType just a few days ago
    George
    Home | Blog

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by georgev
    I learnt about .ControlType just a few days ago
    If you were still on the protege list you would have learnt by now to always throw in any snippets casually (and ideally with a hint of disdain) as though you wrote the functionality a few years ago yourself as opposed to having just hastily consulted google.

    But you are not so you are destined to continue making all these errors during your short career in IT.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    This thread I raised a few days ago is what I'm talking about.

    And admit it Poots - you want me back ;P
    George
    Home | Blog

  5. #5
    Join Date
    Aug 2005
    Posts
    196
    Quote Originally Posted by georgev
    Code:
    Dim Ctl As Control
    
    For Each Ctl In Me.Controls
    If Me(Ctl).ControlType = acTextBox Then
     Me(Ctl).Enabled = True
     Me(Ctl).Locked = False
    End If
    Next
    I learnt about .ControlType just a few days ago
    Perfect! Thanks for your help.

Posting Permissions

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