Unlinked Form/Subform Error No: 2467

gray

Registered User.
Local time
Today, 12:00
Joined
Mar 19, 2007
Messages
578
Hi

I have an unlinked form/subform (i.e. no master/child fields set up). Whenever I try to access any of the subform's resources from the main form in vb code I get an error
Error No: 2467 - Error Decription: The expression you entered refers to an object that is closed or doesn't exist.
I have done all the usual:
- checked the names of the subform and it's controls,
- compacted and repaired,
- deleted and re-added the subform,
- deleted the whole form and re-imported it from a backup DB
but not joy.

I refer to the subform as per the following:-

Code:
Dim Cntrlbx As Control

Set Cntrlbx = Me.Form.Controls("My_Subform_Name") 
Cntrlbx.Form.Controls("Cntcts_Unique_No_Added_By").ColumnHidden = True
The "Set" works OK but all other calls to the subform's form fail as in the ColumnHidden command above?

Instinct tells me this is because I created the offending form by copying a similar Form/Subform (that was working OK) and I bet Access has got all it's resource's knickers in a twist!

Any ideas how to cure it please?
 
Can you post a copy of the database (zipped) after removing anything confidential?
You say no master/child fields set up
How are the form and subform related?
 
Have you tried

me.My_Subform_Name.form.Cntcts_Unique_No_Added_By.ColumnHidden = True

where My_Subform_Name is the name of your subform control (not your subform) and Cntcts_Unique_No_Added_By is the name of the control you are trying to set column width

Also, if you have spaces in your names, vba replaces them with underscores, which means it is not the same, so may be causing a problem
 
Hi

Thanks for the replies.

I tried various nomenclatures for the form/subform/controls which in this case did not turn out to be the problem.

Your questions re- the relationship between the form/subform prompted my memory from about a year ago when I put the original form together. The Mainform builds a recordsource string and applies it to the Subform... alas the original recordsource was still stored and was invalid for this, new copy of, the Subform.

As I recall, Subforms are always opened first. In this case it failed to open because of the dodgy recordsource so when the Mainform tried to reference the Subform in order to apply the new recordsource it could not find it! Somewhere in that story is both a Chicken and an Egg !

Many thanks for your time gents....
 
So, is it working now?
 
Yes... working fine now thznks
 
This just helped me. Saved me from 3 days of chasing my tail.

Thanks.
 

Users who are viewing this thread

Back
Top Bottom