Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1119
  • Last Modified:

Access VBA form controltype subroutine

I'm trying to loop through my form and enable all textboxes.  I have this code:
Private Sub subIntitializeTextBoxes()
'declare a control object variable
Dim ctl As Control

'Loop thru the Controls collection
For Each ctl In Me.Controls
    If Me.ControlType = acTextBox Then
    MsgBox ("Text Box")
    End If
Next ctl
End Sub

My first problems is on the line:
If Me.ControlType = acTextBox Then

on execute I get the error Method or data member not found.   The examples I've seen use this method.  I'm missing something.

Thanks,
Brooks
0
gbnorton
Asked:
gbnorton
  • 2
1 Solution
 
Dale FyeCommented:
if ctl.ControlType = acTextBox Then
0
 
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPCommented:
TIP: In your code the  Me refers to the form object.


Try:
'Loop thru the Controls collection
For Each ctl In Me.Controls
    If ctl.ControlType = acTextBox Then
           degug.print "Text Box: " & ctl.Name  ' prints to the immediate window
           ctl.Enabled  = True
    End If
Next ctl
End Sub

Open in new window

0
 
gbnortonAuthor Commented:
Thanks Fyed
0
 
Dale FyeCommented:
you are welcome.

Happy New Year!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now