dynamically adding conmtrols at runtime to a form...

B

Brad Pears

If I wanted to dynamically add new text box controls (or any control for
that matter) to a form at run time how would I go about doing this?

Thanks, Brad
 
M

Marshall Barton

Brad said:
If I wanted to dynamically add new text box controls (or any control for
that matter) to a form at run time how would I go about doing this?


Making design time changes to a form (or report,macro,
module, table) at runtime is a really big No-No.

What you should do is precreate an adequate pool of
invisible controls and, when needed, make them visible and
set their other properties (Top, Left, etc). Simple and
quick!

Tip - to make the pool easier to manage, name them with a
common prefix (e.g. txtA) and a sequential number suffix.
This way you can use a module level variable to hold the
number of the next available control.

With Me("txtA" & intX)
.Top = . . .
.Left = . . .
.ControlsSource = " . . .
.Visible = True
intX = intX + 1
End With
 
B

Brad Pears

Thanks for that... I was hoping to be able to simple create/remove hidden
controls (to be used for criteria info) on the fly for a particular
application but I suppose I could do what you suggest.

Thanks,
Brad
 
M

Marshall Barton

Working with a precreated set of invisible controls is
actually easier than creating new controls. so don't be too
disappointed ;-)
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
Top