Creating buttons from code

O

Ofer

I'm not sure what you are trying to do, but the way to go around creating a
button is, create the button, set the visible property of the button to
False, and in certain conditions, using code change the visibility of the
button to true

Me.ButtonName.Visible = True
 
P

Paul Witmond

Hi,

Thanks for the quick response.

On the forms I want to show some buttons. Sometimes only 1 but sometimes 25
or more
Creating 25 buttons and hiding them until needed is possible.
Using code to actually create the buttons is better, but is it possible ????

Thanks

Paul
 
O

Ofer

I don't think it is possible.
And the right way will be to change the visibility of the button.
 
G

George Nicholson

A Form has a CreateControl method. Check out VBA Help.

The form has to be open in Design view for this method to work. This can
turn into a pretty big PIB.

Also, AFAIK, design views are not possible (even via code) if using Runtime.
I'm not 100% sure about this, so if you're even *possibly* designing for
Runtime users, make sure it is feasible to do in Runtime before you expend a
lot of time & effort on getting it precise.

HTH,
 
K

Ken Snell [MVP]

And, creating buttons by code means you likely will delete them by code,
which means you eventually run into the 764-control maximum for created
controls....
 
Top