I have a problem I just can't figure out. I have a form with a
subform, and the recordsource of the subform has criteria based on
some unbound fields in the parent form so that data in the parent form
affects data in the subform. I've had this type of setup often, but
I've run across a couple forms where this has caused an "enter
parameter value" pop up for each reference to the parent control in
the query when the main form is closed. I've spent a lot of time
trying to figure out how to solve it, and eventually gave up, and
simply put code into the command button that closes the form to set
the sourceobject of the subform to "" before closing the form. This
doesn't solve the problem if the user clicks the "x" to close the
form, but at least I can tell them to use the command button instead
to avoid the "error". Unfortunately, putting the same code in the "on
close" event doesn't work, because by the time it's triggered, the
subform is apparently already closed, because you then get an error
because you're trying to change the sourceobject of something that
doesn't exist.
I'm now in a situation where the hack of removing the sourceobject via
the command button isn't sufficient. I need to figure out why the
query of the subform is trying to run after the parent has already
started shutting down. I DID have this problem in two places... in
the second one, the reference was in the recordsource of a combobox in
the subform. I had an "on current" event that updated that combobox,
so that is what apparently was triggering THAT query to run on close.
I've changed that code to only requery the combobox if the parent is
still loaded.
The cause for the other form, however, is more elusive. There is no
requerying going on of that form. I can't find any event triggers
that could be causing that data to be refreshed during a close. I've
tried saving the recordsource of the subform to a stand-alone query
and using the query name as the recordsource, and changing the
recordsource of the subform to "" in the on-close event (which
actually made the situation worse: I got the parameter pop-up
repeatedly, apparently possibly once for each record in the table,
rather than just once for each reference).
Any suggestions?
Thanks!