Form limitations - Adding controls

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Has anyone ever had a problem with Access not letting you add controls to a form

I have a form that we dynamically build based on other criteria. When they select from a drop down list, I need to clear all controls on this subform and then re add the appropriate controls. this seems to work for a while, but at some point I must hit an Access limit, b/c I will eventually encounter an error about not being able to add any more controls to this form. I have 9 fields on this form and after I perform this logic 80 times, I get this error. Is there something magic about 720

I use the following code to accomplish this

To open the form in design view while in code..
DoCmd.OpenForm "frmUWInputDistributionGrid", acDesign, , , , acHidde

To delete control
Do While myForm.Controls.count <>
For Each MyControl In myForm.Control
DeleteControl MyFormName, MyControl.Nam
Nex
Loo

To re-add control
For Each MyField In MyRecordSet.Field
ControlName = MyField.Nam
Set MyControl = CreateControl(MyFormName, acTextBox, , , ControlName
MyControl.Name = ControlNam
Nex
 
According to Access Help (VB Help) if you look under Specifications:
Form/Report you will find that:

Number of controls and sections you can add over the lifetime of the form or
report: 754

I don't know if compacting will restore the number or not. You may have to
create the form from scratch each 81st time.

--
--Roger Carlson
www.rogersaccesslibrary.com
Reply to: Roger dot Carlson at Spectrum-Health dot Org

jsr1971 said:
Has anyone ever had a problem with Access not letting you add controls to a form.

I have a form that we dynamically build based on other criteria. When
they select from a drop down list, I need to clear all controls on this
subform and then re add the appropriate controls. this seems to work for a
while, but at some point I must hit an Access limit, b/c I will eventually
encounter an error about not being able to add any more controls to this
form. I have 9 fields on this form and after I perform this logic 80 times,
I get this error. Is there something magic about 720?
 
From Access Help...

Number of controls and sections you can add over the lifetime of the
form or report 754






Has anyone ever had a problem with Access not letting you add controls to a
form.

I have a form that we dynamically build based on other criteria. When they
select from a drop down list, I need to clear all controls on this subform
and then re add the appropriate controls. this seems to work for a while,
but at some point I must hit an Access limit, b/c I will eventually
encounter an error about not being able to add any more controls to this
form. I have 9 fields on this form and after I perform this logic 80 times,
I get this error. Is there something magic about 720?

I use the following code to accomplish this.

To open the form in design view while in code...
DoCmd.OpenForm "frmUWInputDistributionGrid", acDesign, , , , acHidden

To delete controls
Do While myForm.Controls.count <> 0
For Each MyControl In myForm.Controls
DeleteControl MyFormName, MyControl.Name
Next
Loop

To re-add controls
For Each MyField In MyRecordSet.Fields
ControlName = MyField.Name
Set MyControl = CreateControl(MyFormName, acTextBox, , ,
ControlName)
MyControl.Name = ControlName
Next
 
Thanks for the information about the 754. This leads me to 3more questions?

1. Can we query this number at any time to see where we are?
2. What does access consider as the lifetime of the form?
3. I assume this 754 is only adds? I kind of assumed since I was deleting all of the controls and then re-adding them, that I would be starting over each time, but I guess not?
 
Answers inline below.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


jason said:
Thanks for the information about the 754. This leads me to 3more questions?

1. Can we query this number at any time to see where we are?

That information is stored in the system tables but I'm not sure if it would
be of any value to you if you could see it.
2. What does access consider as the lifetime of the form?

Basically it means what it says, although compacting can restore some life,
though not necessarily all if there are gaps in the numbering.
3. I assume this 754 is only adds? I kind of assumed since I was
deleting all of the controls and then re-adding them, that I would be
starting over each time, but I guess not?

No, a form may have 754 objects (and that includes everything on the form).
When an object is deleted the number of that object is simply burned, much
like an AutoNumber value is burned in a table. Compacting the database can
restore some space to you but not necessarily all.
 
The standard way to handle this situation is to add all the controls you need
and then set their visible property to False. You can then set the visible
property of the controls, move them into positions, etc.
 
Back
Top