Enabled property ->" Object does not support..."

J

Jay

Parent form with a subform. One checkbox on parent form, one checkbox on the
subform.

In the Parent form's Current event procedure, I'd like to set the Enabled
property of the subform checkbox relative to the value of the parent form
checkbox.

If the parent form checkbox is True (checked), then disable the subform's
checkbox. If parent form check box is False (unchecked), then enable the
subform's checkbox.

I get a runtime error message "Object does not support this property or
method" from the following parent form code:

Private Sub Form_Current() ' parent form's Current event procedure
Me.SubForm1.Form.TaxExempt.Enabled = Not (Me.TaxExemptClient)
End sub
 
A

Allen Browne

If the object doesn't support the property, it's the wrong type of object.

Firstly check that the name of the subform *control* is Subform1. The
subform control may have a name that's different from the form loaded into
it (its SourceObject.)

Secondly check the name of the check box. If you have a field named
TaxExempt, bound to a check box named (say) chkTaxExempt, then TaxExempt
(the field) won't have an Enabled property, whereas chkTaxExempt (the check
box) does.

If you still can't determine what Access means, ask it.
Press Ctrl+G to open the Immediate Window.
Enter:
? TypeName(Forms![MyMain]!SubForm1.Form.TaxExempt)
 
J

Jay

Hi Allen -

Thanks for taking this one. The problem was indeed related to an
interaction between the checkbox name and the field name. They were both
"TaxExempt".

I incorrectly assumed that the qualifier on TaxExempt would be explicit
enough for Access to understand that I was specifying the checkbox on the
subform and not the AccessField. Wrong again, Jay.

Does this mean that it is essential to name your controls differently from
the fields to which they are bound ?

--
Thanks again,
Jay


Allen Browne said:
If the object doesn't support the property, it's the wrong type of object.

Firstly check that the name of the subform *control* is Subform1. The
subform control may have a name that's different from the form loaded into
it (its SourceObject.)

Secondly check the name of the check box. If you have a field named
TaxExempt, bound to a check box named (say) chkTaxExempt, then TaxExempt
(the field) won't have an Enabled property, whereas chkTaxExempt (the check
box) does.

If you still can't determine what Access means, ask it.
Press Ctrl+G to open the Immediate Window.
Enter:
? TypeName(Forms![MyMain]!SubForm1.Form.TaxExempt)
 
A

Allen Browne

No: it's not essential to name them differently (though some people prefer
to.)

If the control has the same name as the field, the control reference takes
precedence, so the code should have worked. If it did not work, then Access
is confused about what things are called. The most likely source of that
confusion is Name AutoCorrect. More info about the dangers of this
misfeature in:
Failures caused by Name Auto-Correct
at:
http://allenbrowne.com/bug-03.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Jay said:
Hi Allen -

Thanks for taking this one. The problem was indeed related to an
interaction between the checkbox name and the field name. They were both
"TaxExempt".

I incorrectly assumed that the qualifier on TaxExempt would be explicit
enough for Access to understand that I was specifying the checkbox on the
subform and not the AccessField. Wrong again, Jay.

Does this mean that it is essential to name your controls differently from
the fields to which they are bound ?

--
Thanks again,
Jay


Allen Browne said:
If the object doesn't support the property, it's the wrong type of
object.

Firstly check that the name of the subform *control* is Subform1. The
subform control may have a name that's different from the form loaded
into
it (its SourceObject.)

Secondly check the name of the check box. If you have a field named
TaxExempt, bound to a check box named (say) chkTaxExempt, then TaxExempt
(the field) won't have an Enabled property, whereas chkTaxExempt (the
check
box) does.

If you still can't determine what Access means, ask it.
Press Ctrl+G to open the Immediate Window.
Enter:
? TypeName(Forms![MyMain]!SubForm1.Form.TaxExempt)

Jay said:
Parent form with a subform. One checkbox on parent form, one checkbox
on
the
subform.

In the Parent form's Current event procedure, I'd like to set the
Enabled
property of the subform checkbox relative to the value of the parent
form
checkbox.

If the parent form checkbox is True (checked), then disable the
subform's
checkbox. If parent form check box is False (unchecked), then enable
the
subform's checkbox.

I get a runtime error message "Object does not support this property or
method" from the following parent form code:

Private Sub Form_Current() ' parent form's Current event procedure
Me.SubForm1.Form.TaxExempt.Enabled = Not (Me.TaxExemptClient)
End sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top