A2007 Subforms do not appear - do not exist

D

derek

In an A2007 SP1 app with a simple unbound form containing 1 bound subform,
the subform frequently appears BLANK the first time you try to load the
parent. When I say BLANK I don't mean an empty datasheet grid, I mean a
plain white rectasngle. Dropping into debug mode at this point and
attempting to discover the properties of the subform always produces the
error message "Object is closed or does not exist."
It seems like Access just isn't placing the subform into the parent. (there
is data in the recordset).

However, if I then close the parent and re-open it immediately, everything
usually OK. The subform appears.

I have tried numreous "tricks" like reassigning the .sourceobject of the
subform after a half second delay, and these seem to work -- but they only
work in a development environment. In the field,using an mde, with design
permissions locked out, it is not possible to modify the .sourceobject of a
subform with code.

Is there some known issue here I'm not aware of?


Derek.
 
D

derek

Never mind. I found the answer myself tonight. I thought the recordset had
data, but when the app has just been opened, certain global variables are
empty which messes up the underlying query for the subform. If the query
can't complete, the subform doesn't populate. The globals have to be set
prior to opening the form -- putting them in the subform OPEN event is too
late: the recordset is already formed by then, the error has already
occurred and the OPEN event doesn't even run.

However the parent form sets global values too. So after you close and
reopen it, the values are now initialized -- the subform query now
succeeds -- and presto -- success the second time.

derek
 

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