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
gbnortonAsked:
Who is Participating?
 
Dale FyeConnect With a Mentor Commented:
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
All Courses

From novice to tech pro — start learning today.