Creating Buttons

F

FBxiii

Hello.

How do I create command buttons on a form using code?

I want to create a series of buttons with certain properties stored in a
table.

My ultimate goal is to create a 'dashboard' for my DB with the buttons
showing the different menu options, images, etc...
 
K

Klatuu

Actually, Alex, you can, but you really don't want to.
You can open a form in design view, hidden and use the CreateControl method
and saving the form.

But the issue is a form has a life time limit of 754 controls. Not a total
number of controls currently defined, but a real life time limit. If you add
a new control to a form, the count increases by 1, but deleting a control
does not descrease the count. So you form will quicky stop working
altogether.
 
S

sfisher973

Klatuu said:
But the issue is a form has a life time limit of 754 controls. Not a total
number of controls currently defined, but a real life time limit. If you add
a new control to a form, the count increases by 1, but deleting a control
does not descrease the count. So you form will quicky stop working
altogether.

And what the heck is that about? An intentional time bomb?
 
L

Linq Adams via AccessMonster.com

And what the heck is that about? An intentional time bomb?

No, a simple limit, as Dave said! It only becomes "an intentional time bomb"
if a developer is incautious enough to add and delete controls on the fly.
 
S

sfisher973

Linq Adams via AccessMonster.com said:
No, a simple limit, as Dave said! It only becomes "an intentional time bomb"
if a developer is incautious enough to add and delete controls on the fly.
I'm just trying to get a handle on this. You say it's a simple limit. I can
see a limit on the total number of controls in a form, that's about resources
754 is more than resonable.

But if you remove a control you release it's resources. Why and for what
purpose does it not subtract it from the form control counter? I haven't had
need yet (and may never) to add and delete controls on the fly but that
doesn't mean I won't some day, and of course there are otherways to do
things. But after all, the functionallity is built-in to build controls on
the fly and the un-reversible control counter is incongruous with that.

I take it back, its not a time bomb, it's a land mine that will take random
victims forever more.
 
K

Klatuu

I have never been able to figure out why the number 754 or why it is a
cumulative number. I will agree it doesn't make much sense, but I will allow
the MS development team some leeway on this. It must be something internal
that was as developers don't see.

For a number of reasons, I would never consider creating or deleting
controls on the fly. Performance would suffer and it could not be deployed
as an mdb. There are a lot of ways you can manipulate a form's appearance
and functionality without doing that. You can make controls visible or
hidden. You can use tabs that you can also show and hide, You can use
multiple forms within a subform control.

I would say that your argument is akin to saying, I know that the maximum
number of fields in a table is 255, but what if I need more? If you get to
that point, your design needs serious improvment.
 
S

sfisher973

Klatuu said:
I have never been able to figure out why the number 754 or why it is a
cumulative number. I will agree it doesn't make much sense, but I will allow
the MS development team some leeway on this. It must be something internal
that was as developers don't see.

For a number of reasons, I would never consider creating or deleting
controls on the fly. Performance would suffer and it could not be deployed
as an mdb. There are a lot of ways you can manipulate a form's appearance
and functionality without doing that. You can make controls visible or
hidden. You can use tabs that you can also show and hide, You can use
multiple forms within a subform control.

Oh I know all that. I've never had to create controls on the fly and may
never, can't think of a reason why you would in an Client Application. On the
other hand I could see using it in development addin but you would never get
to 754 controls on a single form.

You know I'm just arguing about it because it's nonsensical, and probably
not stated anywhere except here. So it's going to catch some programmer
somewhere, sometime and they're going to spend a lot of time trying to figure
out what happened.

I would say that your argument is akin to saying, I know that the maximum
number of fields in a table is 255, but what if I need more? If you get to
that point, your design needs serious improvment.

I agree totally, right up until I get a CSV file from someone to import with
300 fields. :)
 
K

Klatuu

It already has happened, a couple of times there have been questions about
forms that stopped working. It turned out they did create and delete
controls on the fly.

Now, there is a way to get rid of that count. That is to start over with a
new mdb and copy all the objects from the old mdb. The copy only picks up
the count of the current controls on the object.

As to documenting that fact, I would agree it is not made very obvious, but
then neither is the fix. But that is true of a lot about Access and just
about every other development environment I have been in. You sort of learn
as you go.

That is what is so great about theses newsgroups. It is a fantastic place
to share and to learn. I think I still learn more than I share.
 

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