Solved

Access VBA form controltype subroutine

Posted on 2013-12-31
4
951 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
Comment Utility
if ctl.ControlType = acTextBox Then
0
 
LVL 21
Comment Utility
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
Comment Utility
Thanks Fyed
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
Comment Utility
you are welcome.

Happy New Year!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now