Solved

Access VBA form controltype subroutine

Posted on 2013-12-31
4
977 Views
Last Modified: 2013-12-31
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
Comment
Question by:gbnorton
  • 2
4 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 39748667
if ctl.ControlType = acTextBox Then
0
 
LVL 21
ID: 39748709
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
 

Author Closing Comment

by:gbnorton
ID: 39748713
Thanks Fyed
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39748718
you are welcome.

Happy New Year!
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question