Log in

View Full Version : Form control count



Movian
03-09-2009, 08:56 AM
i on occasion have to create a tool for a specific purpose and realize that it might be useful for others. I believe this has happened again, i was having some problems with the number of controls on forms so had to get a quick count of the number of controls (Due to access's 750 control limit) so i created a form that dynamically creates a list of all the forms in the database and then you can select a form to get the current number of controls. (Of course this does not work for MDE or ACCDE files).

I have exported the form to a text file and attached it to this message. Hopefully it will work. Let me know if it does (i had to zip the file as the forum does not allow .txt files)

So let me know what you think :)

*Edit

Sorry exported it the wrong way. Have replaced the zip file and hopefully this new one should work correctly

you should be able to import the form with the following command
Application.LoadFromText acForm, "ControlCount", strFileName

of course replacing
strFileName with the location of the text file

hansup
03-10-2009, 09:25 AM
i on occasion have to create a tool for a specific purpose and realize that it might be useful for others. I believe this has happened again, i was having some problems with the number of controls on forms so had to get a quick count of the number of controls (Due to access's 750 control limit) so i created a form that dynamically creates a list of all the forms in the database and then you can select a form to get the current number of controls. (Of course this does not work for MDE or ACCDE files).I'm curious about that limit. If a form has only one control, and that control is a subform which includes 100 controls, how many more controls can you add to the parent form before you hit the 750 limit? 749 or 649?

My Access 2003 refused to import your ControlCountForm.txt file. I got error 2285, "Microsoft Office Access can't create the output file". However, looking at the code for events, I think I understand what you're doing.

It appears the form names in the listbox will be presented in the order they are retrieved from CurrentProject.AllForms. If you have many forms, it would be more convenient to list the form names in alphabetical order. You could do that cheaply by using a query based on MSysObjects as the source for your listbox.

SELECT MSysObjects.Name
FROM MsysObjects
WHERE (Left$([Name],1)<>"~") AND (MSysObjects.Type)=-32768
ORDER BY MSysObjects.Name;

]Edit: I copied that query from Dev Ashish at http://www.mvps.org/access/queries/qry0002.htm
He has other sample queries to list names of other types of database objects: tables; queries; reports; etc.]

You don't want to make any changes in MSysObjects, or bad things will happen. But I don't see harm in simply querying it.

A side effect of your approach to opening the selected form is that a form which was already open would be closed afterward. If that matters, you could first check whether the selected form is open (found in the Forms collection) and store its open/closed status in a variable. Then when you are ready to close the selected form, only close it if it wasn't open before you started.

Hans

Movian
03-10-2009, 11:18 AM
Thanks for the input, i will look at making those changes this evening also in answer to your question..

from my experience that limit is semi flexible. I have some forms with 780 controls that work perfectly. I have yet to discover the reason for this

I have had others that break as soon as i hit 755. But the control limit is for each form individually. If you have a form and a sub form i believe you would be able to have 1500 controls between the 2.

hansup
03-10-2009, 12:42 PM
Thanks for the input, i will look at making those changes this evening also in answer to your question..

from my experience that limit is semi flexible. I have some forms with 780 controls that work perfectly. I have yet to discover the reason for this

I have had others that break as soon as i hit 755. But the control limit is for each form individually. If you have a form and a sub form i believe you would be able to have 1500 controls between the 2. Thanks for indulging my curiosity. I hope I never have to bump into that limit.:wot

Hans