Creating Controls with VBA

TurboDieselOne

Registered User.
Local time
Today, 14:31
Joined
Jan 16, 2003
Messages
39
Does any one know what code I would use to creat a control?

Example:-

Click Client Button
Create controls:-
intClientID
txtClientName
txtAddress
cboFeeEarner

etc and then I can set the properties of these controls to where to put them on the form and then create the recordset and set the controls to the appropiate control
 
If I may add to Wayne’s post.

Those demos were originally written for a very specific purpose, namely to simply see if I could do it. I would never use that technique in production code; it is simply a way to ‘knock up’ something for testing.

Two possible reasons come to mind…

1. When controls are created ‘on the fly’ there is no guarantee that they would be destroyed ‘on the fly’, that much you will need to test for yourself. You might get away with it for an hour, or six months, but eventually the application could crash due to ‘too many controls in the life of a form’. Under these circumstances an hour would be preferable to six months.

2. It requires that the form is opened in design view and that can’t happen in an MDE file. You would be locking yourself into and MDB file and that is not the way to go if you wish to hand over your application to some other party.

So please think very carefully about going down this path, it could be a waste of time.

Please don’t let this post stop you from trying, it’s a worthwhile endeavor, but the gains you get may not be just what you originally had in mind. :)


Edit to add.
The code that the code writes is something I do all the time and that’s what I learned.
If we have 3 Event Handlers then that is OK but if we have 400 Event Handlers then that is not OK. Somewhere between 3 and 400 the situation changes. Just when and where that situation changes is entirely up to the person that has to maintain it.

Regards,
Chris.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom