Enable textboxes

Maritza

Information *****
Local time
Today, 22:53
Joined
Nov 13, 2002
Messages
54
Sorry, I press the wrong button, but here it goes again.

The following routine works in some projects, and doesn't work others.

Sub EnableText()
Dim ctl as Control

For each ctl in me.controls
If ctl.ControlType = acTextBox
with ctl
ctl.enable = true
end with
end if
next ctl


The error that I get is the following: "Object doesn't support this property or method". Does any one know how to fix it, and what is causing it.

Thanks
 
Is this in a public module? If so, you can't use Me to refer to the form. You need to reference it directly.

One thing you can do is this:

For Each ctl in Screen.ActiveForm.Controls

That will be available to all forms.
 
Enable Routine

I just tried using Screen.ActiveForms.control. I still get the same error. Also, the sub is not a private sub, and it is in the module of the form that I'm trying to modify. Any more suggestions?

Thanks
 
Well then I would suggest setting it up the way I do:

Sub EnableText()
Dim ctl as Control

For each ctl in Forms!FormName.Controls
If TypeOf ctl is Textbox then
ctl.Enabled=True
end if
next ctl
 
Enable Routine

It works! It's unbelievable. It wouldn't work with
me.controls
screen.activeform.controls

But it works with Forms!FormName.Controls

Thanks Again
 

Users who are viewing this thread

Back
Top Bottom