Re: Disable All Controls on a SubForm
- From: "Sandra Daigle" <Invalid@xxxxxxxxxxxxxxxx>
- Date: Fri, 17 Mar 2006 10:49:07 -0500
How are you changing focus to the main form? If focus is actually on the main form then your code should work. I did a little test and when I tried to disable all subform controls by clicking a button on the main form I discovered that the subform (which previously had the focus) did in fact still have the focus until AFTER the button click event had completed. So, by adding a setfocus statement to the button click event, I was able to disable all controls.
Me.Command5.SetFocus
For Each ctl In Me.Child0.Form.Controls
ctl.Enabled = Not ctl.Enabled
Debug.Print ctl.Name
Next ctl
Note that without error handling, this code doesn't work since labels don't have an Enabled property. If you are using a loop you need to include error handling or logic to not attempt changing the enabled property on controls that do not have the property.
--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.
"Rick A" <allisonrja@xxxxxxxxxxx> wrote in message news:u43zaVdSGHA.5500@xxxxxxxxxxxxxxxxxxxxxxx
I want to set enable=false for all controls on a subform but I cannot do that because one control needs focus. At least that is what I am lead to believe.
Code
subform.form!control.enable = false
Perhaps my real question is why does a control on the subform have focus when I've changed focus to a control on the main form. I would think that since focus is on a main form control no control on the subform would have focus.
Any help is appreciated.
--
Rick Allison
- Follow-Ups:
- Re: Disable All Controls on a SubForm
- From: Rick A
- Re: Disable All Controls on a SubForm
- Prev by Date: Menu
- Next by Date: Re: Access 2003 and null vs. 0
- Previous by thread: Menu
- Next by thread: Re: Disable All Controls on a SubForm
- Index(es):