assigning event procedure to control at runtmie?

  • Thread starter Stephan Hagemann
  • Start date
S

Stephan Hagemann

I have some ListBoxes, that I create at runtime. I need them to react to
user commands. How can I assign event procedures to these at runtime?

Thanks,
Stephan
 
M

Marshall Barton

Stephan said:
I have some ListBoxes, that I create at runtime. I need them to react to
user commands. How can I assign event procedures to these at runtime?


Create at run time???

This can not be done in Access, controls can only be created
in design view.

if you're opening the form in design view, creating some
controls and switching to form view, you are begging for
serious problems in your application.

A far more stable (and easier) approach is to precreate all
the controls you will ever need and make them visible as
needed.
 
S

Stephan Hagemann

Create at run time???

yes. Using createControl.

During operation I automatically switch the form to design mode and switch
back once the create process is finished. That works nicely, only that I
now would like to add event reactions.

Stephan
 
R

Rick Brandt

Stephan Hagemann said:
yes. Using createControl.

During operation I automatically switch the form to design mode and switch
back once the create process is finished. That works nicely, only that I
now would like to add event reactions.

You do realize that Access forms have a "lifetime limit" on the number of
controls added to them, right? Adding controls at Runtime will eventually
cause you to hit this limit and start throwing errors.

(I believe it's around 700 and something)
 
M

Marshall Barton

Stephan said:
yes. Using createControl.

During operation I automatically switch the form to design mode and switch
back once the create process is finished. That works nicely, only that I
now would like to add event reactions.


You're deluding yourself, that approach does not work
nicely. (I'm being blunt for the sake of emphasis, not to
belittle your knowledge.)

The CreateControl function's purpose is for use in design
time wizards and has no other rational use.

Design changes, especially large objects such as forms and
reports, affect a large part of the mdb file, which in turn
greatly increases the chances of corruption. It also causes
massive bloat, and because of the lifetime limit of 754
controls on a form/report will eventually fail. Not only
that, but if you should ever decide to make your app an mde,
it just plain will not work at all.

I've been down this road and I wish I had had someone around
to point me down a better path without having to suffer
through all the troubles it caused me. Please believe me,
it really is far better, as well as easier, to make
precreated controls visible than to deal with the
consequences of making design changes at runtime.
 

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