Disabling a field in a form while it's open

PortyAL

Craigavon, N.Ireland
Local time
Today, 23:34
Joined
Apr 16, 2007
Messages
24
Hi

I have a form and I want to disable some fields depending on whether a check box on the form is ticked.

I've tried:

Code:
 Forms![formname].Controls(fieldname).Enabled = False

but I get an error message:

"Run-time error '2164':
You can't disable a control while it has the focus."


Any help would be greatly appreciated.

Thanks

AL
 
Just set the focus to some other control before disabling:

Forms![formname].Controls(fieldname2).SetFocus
Forms![formname].Controls(fieldname).Enabled = False
 
Thanks but...

If I try that I get the message Object doesn't support this property or method

I've tried it with several fields but get the same error.

AL
 
Are you making sure to set the focus to a control that can accept the focus? Try using this syntax instead if the code is on the form where you are trying to do this:

Me.YourTextBox2Name.SetFocus
Me.YourTextBoxNameToDisable.Enabled = False
 
Brilliant!

Working now!

Much appreciated.

AL
 

Users who are viewing this thread

Back
Top Bottom