Invalid reference Error 2455 - Is it Access 2000 bug? (1 Viewer)

StephenS

Registered User.
Local time
Today, 09:53
Joined
Mar 24, 2000
Messages
31
I get this error when referring to the property of a control on a subform. I am using the OnCurrent event with the expression

Me!subfrmControlName.Form.[ControlOnSubformName].Enabled = False

I have also tried ...

Forms!FormName!subfrmControlName.Form.[ControlOnsubfrmName].Enabled = False

Also...

Forms!FormName!subfrmControlName!ControlOnSubfrmName.Enabled = False

Nothing seems to work. The first used to work. I changed some things (not the names of anything) and then it no longer worked. Has anyone run into this problem before? Is it a bug? I also wrote a previous subject "Invalid Reference Nightmare" earlier this morning. I wonder if they are related.

StephenS
 

llkhoutx

Registered User.
Local time
Today, 04:53
Joined
Feb 26, 2001
Messages
4,018
Try using the expression building when building the expression. The exxp[ression builder is 99.99% accurate.
 

StephenS

Registered User.
Local time
Today, 09:53
Joined
Mar 24, 2000
Messages
31
Have tried the expression builder. It does not appear to pick up on any of the controls on the subform. According to Alison Balter's book on Access 2000 Development p 344, changing the property of a control on a subform uses the syntax:

Forms.frmCustomer.fsubOrders!txtOrderID.Enabled = false

In this example, fsubOrders is the name of the control on the main form and txtOrderID is the name of the control on the subform. The expression builder (for me) gets as far as the "fsubOrders" part of the above statement. It does not list any of the controls even when I use a period (.) instead of an exclamation (!). The subform seems to be properly linked by a key field. This is why I wonder if I am missing an obscure link or if there is a bug.

StephenS
 

Fornatian

Dim Person
Local time
Today, 09:53
Joined
Sep 1, 2000
Messages
1,396
Have you tried right clicking in the code and choosing 'build'. This will bring up the expression builder. In the first column scroll down until you see loaded forms(it should have a plus sign to indicate theres more to see). Double click to open the loaded forms folder. Your parent form should have another plus on it, double click that, your subform should be visible there. Click it and choose fields from the second column, this should show you only the fields in the subform. Double click the appropriate field and choose OK, this will put the correct syntax into the code module.

Everything should be hunky dory from there on.

Ian
 

StephenS

Registered User.
Local time
Today, 09:53
Joined
Mar 24, 2000
Messages
31
Right clicking in my code doesn't give me "build" as an option. It gives the following: Cut, Copy, Paste, List Properties/methods, List Constants, Quick Info, Parameter Info, Complete Word, Toggle, Object Browser, Add Watch, Definition, Last Position, and Hide.

StephenS
 

Atomic Shrimp

Humanoid lifeform
Local time
Today, 09:53
Joined
Jun 16, 2000
Messages
1,954
I suspect that the 'Build' option is missing from your right-click menu because the you're still running the code, perhaps you've stopped at a breakpoint?

To get the expression builder in the code window, you have to open the form in design view, then View/View Code - then what Ian describes above should work.

Mike
 

StephenS

Registered User.
Local time
Today, 09:53
Joined
Mar 24, 2000
Messages
31
No, I was not running the code at the time. I went from design view into the code and right-clicked on an empty spot. 'Build' was not one of the options. So here's what I'm doing or planning to do right now.

- ReInstall Access 2000 in the next day or so if nothing changes (though my first install had about everything!).
- Continue checking the Microsoft Knowledge Base (nothing yet)
- Look for any references that may be missing (I still wonder if my previous topic 'Invalid Reference Nightmare' may be related).
- Drink lots of coffee - done

Would love more ideas/help - the idea to use 'build' probably points to a related problem. I will post anything I find out should I find the cause.

StephenS
 

Atomic Shrimp

Humanoid lifeform
Local time
Today, 09:53
Joined
Jun 16, 2000
Messages
1,954
In that case, it certainly sounds to me as if something has gone a bit wrong either during or since installation.

Had you installed all of the available service packs for your version BTW?

I've reverted to A97, I know it's probably not all that clever an idea, but I just found A2K generally buggy and unstable.

Mike

[This message has been edited by Mike Gurman (edited 03-14-2001).]
 

StephenS

Registered User.
Local time
Today, 09:53
Joined
Mar 24, 2000
Messages
31
Could it be the 'Build' option has been dropped in Access 2000? So far I have Re-Installed Access 2000 with everything. When that didn't get it, I uninstalled it and re-installed it again. Next, I installed the SP5 upgrade that was on the MS download website for Access 2000.

Finally checked a machine that had MS Access 97 on it (discovered my organization's network support has also reverted to 97). Sure enough, right-click in the code section and the build icon is available.

Conclude problem with installation not likely. If anyone knows different for sure - let me know. Am running NT4 version.

Moving back to debugging Invalid reference Error. May have to find work-around should nothing turns up soon. Will update.

StephenS
 

Atomic Shrimp

Humanoid lifeform
Local time
Today, 09:53
Joined
Jun 16, 2000
Messages
1,954
You're right A2K doesn't seem to make the expression builder available from the right-click menu in the code view.

My search continues, I'll keep you posted.

Mike
 

Fornatian

Dim Person
Local time
Today, 09:53
Joined
Sep 1, 2000
Messages
1,396
The correct syntax to use is:

Forms![frmExportOrderHeader]![frmExportOrders].Form![Country].enabled = False

where frmExportHeader is the parent
frmExportOrders is the subform and
country is the field.

(I copied this straight out of the expression builder, so it had better be right!!!!)

Maybe its a punctuation error, I suggest copying my example above and just replacing the names and see what happens. You know what its like when you have a bad period(hee,hee!)


Ian
 

StephenS

Registered User.
Local time
Today, 09:53
Joined
Mar 24, 2000
Messages
31
Sorry for slow reply. Have been in "Work-around" mode for the last couple days. Believe your syntax is correct but has not worked. Not sure how to answer your remark on "bad periods". My wife would know...

Addressing controls on subforms in Access 2000 seems fragile. It worked on an earlier version of this application in 2000 (slightly different structure). Recently had to go back to earlier version to make changes. One change was to add the ability to go to a record that has just been added. Instead of always moving to the last record using say "DoCmd.GoToRecord acLast", it needed the ability to go to any record. Looks like ("DoCmd.GoToRecord, , acDataForm, "frmName", acGoTo, Recordno"). When this command was added, the addressing error (invalid reference) popped up for the first time. Syntax error looks unlikely.

The bad references to the subform occur in the OnCurrent Event of the parent form. The new version doesn't work even without the "GoToRecord" change. If any ideas or you want more info, Love to hear it. If not, I hope this info is of help to someone.

StephenS
 

Users who are viewing this thread

Top Bottom