Subform Recordsource changes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have been attempting to create a form-subform relationship in which a user
can select a query from a list and have the records displayed in the subform.
The problem is that the subform controls must be specified at the start and
changing the recordsource will change the fields being displayed. As a
consequence some data is lost. One solution would be to create a subform for
each query but I would like a solution based on modifying the structure of
the subform. Or alternately creating (and ultimately destroying) a temporary
subform for each query.

What are my options and how can I proceed. Ican't seem to find a similar
problem in the archives.
 
That's because the approach you want to take is a lot of work.

You could write a lot of code to add and delete fields on the subform,
change their control source, re-position them, possibly change their tab
order, etc. It's all doable by opening the form for design (keeps it
hidden), making your changes, and then doing a docmd.save (specify form and
save=yes). But it is a LOT of work.

You could make it a bit easier by having the subform be a datasheet view
with "generic" columns (field1, field2, field3). You could then dynamically
assign the control source for each column based on which query was selected
(you could even dynamically assign the column heading).

If the datasheet approach won't fly, then the easiest approach is probably
to have a separate subform for each query, and then make them all invisible
except for the one needed based on the query selected.
 
Thanks

I've come to the same conclusion but have decided that the TreeView control
is probably the better way to display the hierarchial data set.
 
Back
Top