Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable all text boxes in a Form

Status
Not open for further replies.

OOzy

Programmer
Jul 24, 2000
135
SA
Dears,

How can I disable all text boxes in a form (Enable=False) programmatically without typing:

a.Enabled=False
b.Enabled=False
c.Enabled=False
d.Enabled=False
e.Enabled=False
 
Hi, you can use the following...

Code:
Dim ctrl As Control

'loop through all form controls
For Each ctrl In Me.Controls
  'if control is a Text Box
  If TypeOf ctrl Is TextBox Then
      'set enabled to false
      ctrl.Enabled = False
  End If
Next ctrl

There are two ways to write error-free programs; only the third one works.
 
OOzy,

A simple search would have given you plenty of examples.

Try this link, scroll down and take a look at the code I posted and followed up by TheAceMan1.


Search Access Help... for

Type ... ControlType in the VBE window
highlight it, hit F1

Enjoy...





AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
Thank you all. Your posts were really helpful and I am sorry for not searching befor posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top