Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access VBA form controltype subroutine

Posted on 2013-12-31
4
Medium Priority
?
1,072 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 49

Accepted Solution

by:
Dale Fye earned 2000 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 49

Expert Comment

by:Dale Fye
ID: 39748718
you are welcome.

Happy New Year!
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

886 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