Turning off/on a sub form

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I have a sub form that slows down the main form somewhat. Is there way to
switch off the sub form somehow so it does not take any resources ie does
not return any related child records but can also be switched on when
needed?

Thanks

Regards
 
you'll have to "unset" the subform control's SourceObject, LinkChildFields,
and LinkMasterFields properties, and then reset them when you want to see
child records. you might run into problems trying to set the linking
properties to null or zero-length strings; if so, play with the order of
setting/resetting the properties and if necessary introduce an unbound blank
form as the SourceObject rather than using a zero-length string or null.

hth
 
John,

Tina's suggestions are good ones.

An alternative approach, depending on your usage scenario, is to remove
the subform's Record Source, and hide it (set Visible property to No).
Then, if you need to access the subform, use code to assign its Record
Source and Visible properties.
 
I thought of this too but even when not visible the records would still
'appear' so visible=true would mean an instant response but visible=false
would still be slow.
 
Jason,

You appear to have missed my comments about the Record Source of the
subform.
 
actually, Steve, i'd say tina's suggestions are fair - i like your
suggestion better, it's much simpler, and i'm going to test it out next time
i have a scenario that fits. :)
 
Removing the record source would mean fast response until a record source is
provided which would be added with the visible command.
 
Jason,

Right. You seem to be getting the idea now. Good solution, don't you
think?
 
Back
Top