Invalid Reference

G

Guest

Access 2002
Making some major changes to an old application. Working on the main form,
on closing and reopening am now getting "You entered an expression that has
an invalid reference to Form/Report". The form continues to open after
clicking "OK" (which is the only choice). I have run the form through all of
its paces with no error. Have opened all the subforms on the form, none
repeat that msg.

Have checked every thing I can think of w/o success. The on current event
fires after this msg so I can't step through a debug process. I am at a loss
how to proceed.

Any ideas on how to find the problem would be appreciated.
 
M

Marshall Barton

Clyde said:
Access 2002
Making some major changes to an old application. Working on the main form,
on closing and reopening am now getting "You entered an expression that has
an invalid reference to Form/Report". The form continues to open after
clicking "OK" (which is the only choice). I have run the form through all of
its paces with no error. Have opened all the subforms on the form, none
repeat that msg.

Have checked every thing I can think of w/o success. The on current event
fires after this msg so I can't step through a debug process. I am at a loss
how to proceed.


You can place breakpoints in your code before you open the
form. Most likely, the issue is in one of the subform's
Open, Load or Current events.

That message usually(?) is caused by a subform referring to
the main form or another subform in the initial events.
Because the subform's opening processing is done one after
another (in the order they were added to the main form) and
before the main form, you can not make that kind of
reference until they have "stabalized" (i.e. not until after
the referenced object's first Current event).
 
G

Guest

Thanks Marshall, I had previously placed a break point in the current of the
main form. Didn't realized that the subfrms might load ahead of the main.
Turns out that the first sub to load referenced a control on the next sub
which hadn't loaded yet!
 
M

Marshall Barton

Clyde said:
Thanks Marshall, I had previously placed a break point in the current of the
main form. Didn't realized that the subfrms might load ahead of the main.
Turns out that the first sub to load referenced a control on the next sub
which hadn't loaded yet!


Ok? It's nice to know I made an accurate diagnosis, but did
you resolve the problem?
 
G

Guest

Sorry (when I replied I knew your suggestion had found the problem but hadn't
resolved yet). I really needed that line of code in the current event of the
subfrm, so I just trapped the error, set the variable to 0 ( which is an
acceptable value) and resumed next.
Once the next sub loaded the code works perfectly. So the only problem was
on loading the main form.
Thanks again.
 
M

Marshall Barton

Clyde said:
Sorry (when I replied I knew your suggestion had found the problem but hadn't
resolved yet). I really needed that line of code in the current event of the
subfrm, so I just trapped the error, set the variable to 0 ( which is an
acceptable value) and resumed next.
Once the next sub loaded the code works perfectly. So the only problem was
on loading the main form.


Excellent solution!

Thanks for posting it.
 

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