Link to home
Start Free TrialLog in
Avatar of Dale Fye
Dale FyeFlag for United States of America

asked on

Err:2455 invalid reference to the property Form

I have a form which contains a subform which has a control name of sub_Well_Details.  This subform contains some text boxes and also contains a continuous subform (sub_Well_Component_Details).  Note that these are the control names, not the name of the forms.

The main form contains a treeview, and if the node selected is at the second level, I make sub_Well_Details visible, but I would also like to disable the Edit and Remove buttons on sub_Well_Component_Details if there are no records in the 2nd level subform.  To do this I'm using the following code in the nodeclick event of the treeview control.

Dim frm as Form
set frm = me.sub_Well_Details.form.sub_Well_Component_Details.Form   <--- problem is here
frm.cmd_Remove.Enabled = frm.REcordsetclone.recordcount
frm.cmd_Edit.Enabled = frm.cmd_Remove.Enabled

but the line beginning "set frm = " is generating the 2455 error "You entered an expression that has an invalid reference to the property Form/Report."

I have compacted, decompiled, checked my references, but nothing I do has resolved this problem.  I know I have used this syntax before for refering to controls on forms and for setting references to forms.

I've also tried:

set frm = forms("frm_Well_Components").sub_Well_Details.form

and

set frm = form_frm_Well_Components.sub_Well_Details.form
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Is there any change that sub form object does not yet exist at the time the code is executed ?

mx
How about this Dale:
 
With me.sub_Well_Details.form.sub_Well_Component_Details.Form   <--- problem is here
     .cmd_Remove.Enabled = .Recordsetclone.recordcount
     .cmd_Edit.Enabled = .cmd_Remove.Enabled
End With

mx
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dale Fye

ASKER

Joe, I was unable to resolve this problem until I imported everything into a new accdb, so my project must have experienced some form of corruption.