Inserting Subform Programattically

  • Thread starter Thread starter dk
  • Start date Start date
D

dk

Does anyone know how to insert a subform at runtime?

I need to do this because I have a form that has to dynamically populate
with a series of subforms depending on how many records it sees in a query.
Thus if there are 5 records in my query I need to create 5 subforms and
populate them accordingly.
 
dk said:
Does anyone know how to insert a subform at runtime?

I need to do this because I have a form that has to dynamically
populate with a series of subforms depending on how many records it
sees in a query. Thus if there are 5 records in my query I need to
create 5 subforms and populate them accordingly.

If there is a small number of these forms you could make them invisible but
unles you can guarentee there will never be more that the ones you create,
it will be a problem.
You could use a continuous form or just have them page through a regular
form
 
I tried the continuous forms. Problem is that continuous forms cannot
contain subforms, and that has led me to trying this option.
 
That option is going to blow up in your face sooner or later.

Perhaps if you could describe what it is you are trying to do, perhaps we
can offer a how to.
 
dk said:
I need to do this because I have a form that has to dynamically populate
with a series of subforms depending on how many records it sees in a query.
Thus if there are 5 records in my query I need to create 5 subforms and
populate them accordingly.

Please explain why you need different subforms as this sounds a bit
unusual.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Thank you all for coming to my aid.

You asked for me to explain what I'm trying to do, so here goes...

I'm going to give an abstraction:

- Our user will be entering data from mailed applications and he will be
doing it in a series of forms, say A, B, C, which CAN EXIST IN ANY
COMBINATION. For example, there can be 2 A's, no B's and 1 C. The
application takes on a model like this:

a*A + b*B + c*C - where a,b,c can be any posiitive integer or zero.

Now my colleague wants to flash all these forms back at the user so that
there is a final chance to review their work. The whole series of forms need
to be populated back in another form (because it needs the functionality of
the form environment - i.e. EDIT buttons).

This theoretically could have been done with a variable subform that will be
defined record-for-record at runtime. But Access won't allow subforms to
appear in continuous forms, and we prefer to put this in one form, rather
than several conitnuous pages.

So I went on a quest looking for ways to "insert" a subform. The insertion
will be looped so that the full series will be inserted in one the big form
one after the other.

I recently discovered the command CreateControl(). But since I have been
doing other things (this was just a side thing I was helping with), I haven't
gone back and tried it yet.
 
Back
Top