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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable all fields in a form

Status
Not open for further replies.
Jun 4, 2003
58
US
Is there a visual basic way to say...

If Project Manager = "John Doe", Then Disable all Textboxes

I have about 30 textboxes, so I want to avoid...
If Me.Project_Manager.Value = "John Doe" Then
Me.Textbox1.Enabled = False
Me.Textbox2.Enabled = False
'etc...

Any help or alternate solutions will work.

Thanks
 
yup, not too difficult at all,

dim ctl as Control

for each ctl in me.controls
if ctl.type = acTextBox then
ctl.enabled = false
end if
next ctl

let me know if this works
 
Try
[blue][tt]
Dim ctl As Control
If Me.Project_Manager.Value = "John Doe" Then
For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Then
ctl.Enabled = False
End If
Next ctl
End If
[/tt][/blue]
 
You might also consider the following:

If Me.Project_Manager.Value = "John Doe" Then
Me.AllowEdits = False
Else
Me.AllowEdits = True
End if




"I know what you're t'inkin', ma petite. Dat Gambit... still de suave one, no?"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top