Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Inserting Subform Programattically

Geek News

Inserting Subform Programattically
dk 11/12/2008 8:49:13 PM
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.
Re: Inserting Subform Programattically
"Mike Painter" <mddotpainter[ at ]sbcglobal.net> 11/12/2008 9:12:18 PM
dk wrote:
[Quoted Text]
> 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


Re: Inserting Subform Programattically
dk 11/12/2008 10:58:31 PM
I tried the continuous forms. Problem is that continuous forms cannot
contain subforms, and that has led me to trying this option.


"Mike Painter" wrote:

[Quoted Text]
> dk wrote:
> > 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
>
>
>
Re: Inserting Subform Programattically
"Klatuu" <david.hargis[ at ]realpage.com> 11/13/2008 9:17:43 PM
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" <dk[ at ]discussions.microsoft.com> wrote in message
news:3E727A3E-A720-410F-8C55-43DA63EC3883[ at ]microsoft.com...
[Quoted Text]
>I tried the continuous forms. Problem is that continuous forms cannot
> contain subforms, and that has led me to trying this option.
>
>
> "Mike Painter" wrote:
>
>> dk wrote:
>> > 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
>>
>>
>>


Re: Inserting Subform Programattically
"Tony Toews [MVP]" <ttoews[ at ]telusplanet.net> 11/19/2008 5:30:05 AM
dk <dk[ at ]discussions.microsoft.com> wrote:

[Quoted Text]
>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/
Re: Inserting Subform Programattically
dk 11/19/2008 4:54:09 PM
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.


"Tony Toews [MVP]" wrote:

[Quoted Text]
> dk <dk[ at ]discussions.microsoft.com> wrote:
>
> >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/
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net