VBA code broke in migration from 2003 to 2007

C

Clay_LMCO

I have some very extensive VBA code using Access forms for the UI. While
migrating from Access 2003 to Access 2007 I have encountered a problem with
the "visibility" of subform controls and their properties in my VBA code.

One of two things happens when the problem occurs:
1. The code behaves as if I have put in a "On Error Resume Next" statement
and ignores any problems.
2. I get the following error - "The expression you enetered refers to an
object that is closed or doesn't exist."

The problem appears to be triggered after I change the RecordSource property
of the subform. I have written code that will search for the control objects
starting with the Application.Forms property and searching down through the
subforms to get to the controls, but this is very cumbersome and performance
is slow.

Has anyone encountered this and found a fix?

Thanks.
 
J

Jeff Boyce

Clay

I've run across a similar behavior, both in migration to Access 2007 and in
migration to previous versions from (even) earlier versions.

What worked in my situations was inspecting all the VBA for the use of the
"dot" instead of the "bang". This may no longer be applicable, but it
appeared that if I took the easy way in referring to a control:

Me.MyControlName

to gain the advantage of the Intellisense completion, in some subsequent
versions, Access complained. When I converted that to:

Me!MyControlName

Access accepted and compiled the changed syntax.

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
C

Clay_LMCO

Thanks, Jeff. It was a good try but it unfortunately did not fix my problem.

--
Clay Watson
Lockheed Martin Aeronautics Company
Ft. Worth, Texas


Jeff Boyce said:
Clay

I've run across a similar behavior, both in migration to Access 2007 and in
migration to previous versions from (even) earlier versions.

What worked in my situations was inspecting all the VBA for the use of the
"dot" instead of the "bang". This may no longer be applicable, but it
appeared that if I took the easy way in referring to a control:

Me.MyControlName

to gain the advantage of the Intellisense completion, in some subsequent
versions, Access complained. When I converted that to:

Me!MyControlName

Access accepted and compiled the changed syntax.

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
M

Mike Painter

Is the file in a trusted location?
That fixes a lot of problems.

Try cutting and pasting the existing code into another routine, then
renaming.
I've seen that work for me with queries in subforms twice now.
Make sure that no reserved words are being used.
Extra milk and cookies for the brownies.
Are you running the code in 2007 or did you convert it?
 
C

Clay_LMCO

Thank you Jeff, Mike, and AccessVandal for the comments. I still don't have
a fix yet, but I avenues to explore. I will be going back to my original
development/testing forms and rebuild my libraries from there. At this point
I don't see any shortcuts.

Based upon what I see with other Access developers, I am doing some
unconventional things. For example, I have embedded pointers to subforms
within VB class objects to encapsulate tool libraries I use across numerous
applications. It has resulted in higher levels of reusable code, big savings
in programming time, and even has performance benefits. However, it also
seems to put my problem into uncharted territories.

I am sure that the problem I am having has to do with persistence of object
pointers within my class library and is tied specifically to subforms.
Everything still works great at the parent form level. Is anyone aware of a
change in Access 2007 that would result in loss of persistence for subforms?
 
C

Clay_LMCO

I believe I have found the problem! Apparently the new version of MS Access
is multithreaded in ways that it was not in previous versions. What is
happening is that I have "critical sections" in my code that are being called
by multiple threads and the local variables are getting clobbered.
ARRRRGH!!!!!

At least I know what is happening. Thanks again to all that tried to help.
 
M

Michael J. Strickland

Clay_LMCO said:
I have some very extensive VBA code using Access forms for the UI.
While
migrating from Access 2003 to Access 2007 I have encountered a problem
with
the "visibility" of subform controls and their properties in my VBA
code.

One of two things happens when the problem occurs:
1. The code behaves as if I have put in a "On Error Resume Next"
statement
and ignores any problems.
2. I get the following error - "The expression you enetered refers to
an
object that is closed or doesn't exist."

The problem appears to be triggered after I change the RecordSource
property
of the subform. I have written code that will search for the control
objects
starting with the Application.Forms property and searching down
through the
subforms to get to the controls, but this is very cumbersome and
performance
is slow.

Has anyone encountered this and found a fix?

Thanks.


It sounds like it might be a reference problem.

One thing to remember is that Access 2007 went back to using DAO as the
default data access package so you might want to check your
references/declarations and make sure they are correct.



--
 

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