Dynamically add controls at run-time

S

Svein Engebretsen

I would like to add controls to a form at run-time. Is it possible?

Aprecciate any answers.

Svein Engebretsen
Oslo, Norway
 
G

Geof Wyght

Svein,
Yes it is. Try the CreateControl method. But, based on my
experience it is a lot of effort. If you create a control
you also have to create and assign VBA to it, if you want
to use VBA. I would rather create the controls and the
make them visible when needed.
Geof.
 
M

Marshall Barton

I have to argue that simple Yes, Geof. While it certainly
is possible to use Create<object> methods in a running
application, the methods are still design operations that
bring all their attendent issues into play. Massive bloat,
greatly increased oportunity for corruption and the
inability to use RunTime installations being the most
serious issues. The first two of those issues require
additional mechanisms (frequent Compacts, more rigorous
backup schemes, etc) in attempts to deal with the near
inevitable problems.

I **strongly** agree that the right way to do this kind of
thing is to precreate the needed controls and manipulate
their properties at run time.
 
G

Geof Wyght

Good points I hadn't thought of. When I tried doing this I
gave up when I realized I had to add my own events.
Instead I let my users have up to X number of controls.
Geof.
-----Original Message-----
I have to argue that simple Yes, Geof. While it certainly
is possible to use Create<object> methods in a running
application, the methods are still design operations that
bring all their attendent issues into play. Massive bloat,
greatly increased oportunity for corruption and the
inability to use RunTime installations being the most
serious issues. The first two of those issues require
additional mechanisms (frequent Compacts, more rigorous
backup schemes, etc) in attempts to deal with the near
inevitable problems.

I **strongly** agree that the right way to do this kind of
thing is to precreate the needed controls and manipulate
their properties at run time.
--
Marsh
MVP [MS Access]



Geof said:
Svein,
Yes it is. Try the CreateControl method. But, based on my
experience it is a lot of effort. If you create a control
you also have to create and assign VBA to it, if you want
to use VBA. I would rather create the controls and the
make them visible when needed.
Geof. it
possible?

.
 
M

Marshall Barton

Sure thing that adding the event procedures is a serious
complication for the developer and it further enhances(?)
the chances for corruption as the compiler gets involved.

I really go for the up to X controls, as long as X is a
reasonably big number ;-)
 
G

Geof Wyght

I had a form with tab controls. The hospital was
recording cormobitities. There were about 6 controls per
comorbitiy. I gave them 20 comorbitiies, 4 per tab
control. It was a big effort.
Geof.
-----Original Message-----
Sure thing that adding the event procedures is a serious
complication for the developer and it further enhances(?)
the chances for corruption as the compiler gets involved.

I really go for the up to X controls, as long as X is a
reasonably big number ;-)
--
Marsh
MVP [MS Access]


Geof said:
Good points I hadn't thought of. When I tried doing this I
gave up when I realized I had to add my own events.
Instead I let my users have up to X number of controls.
Geof. on
my Is
it
.
 
M

Marshall Barton

That sounds like it was pretty tricky, but I'll bet it
worked out very nicely.

I had a really nasty one once that diplayed a variable
number of year columns with various totals under each, kind
of like a crosstab but updateable (don't ask). The real
killer was that the number of displayed years was clickable
and could be shifted left or right. Lots of fun, but very
cool ;-)

Keep up the good work, Geof.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top