Jim Dettman
jimdettman at verizon.net
Tue Dec 13 08:31:59 CST 2011
The default control names may have something to do with it, but it's not the entire answer. I just ran the code below in A2003 and was able to create 895 controls. I tried the same code in other versions as well: A2000 - 800 A2002 - 894 A2007 - 1040 A2010 - 1040 Apparently the control creation limit is not a hard limit, but based on some other internal constraint. This is similar to the table ID limit, which is stated as 2048, but actually floats a bit. These limits are somehow tied to the way Access internally handles open objects, but what that process is is un-clear. Jim. Public Sub CheckControlCreation() Dim frm As Form Dim ctlText As Control Dim ctlLabel As Control Dim intK As Integer ' Create form based on Customers form. Set frm = CreateForm() For intK = 1 To 2000 ' Create unbound default-size text box in detail section. Set ctlText = CreateControl(frm.Name, acTextBox, acDetail, , , 100 + intK, 100 + intK, 200, 200) ' Create child label control for text box. Set ctlLabel = CreateControl(frm.Name, acLabel, , ctlText.Name, "", 100, 100) Debug.Print ctlText.Name, ctlLabel.Name Next intK End Sub -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of William Benson Sent: Monday, December 12, 2011 07:37 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Form Lifetime Control Limit (Was: Advice on A2010....) Great explanations. Thanks Mark and Ken. On Dec 12, 2011 6:22 PM, "Darryl Collins" <darryl at whittleconsulting.com.au> wrote: > Thanks Ken, > > That is a good and clear explanation. > > Cheers > Darryl. > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com [mailto: > accessd-bounces at databaseadvisors.com] On Behalf Of Kenneth Ismert > Sent: Tuesday, 13 December 2011 8:27 AM > To: accessd at databaseadvisors.com > Subject: Re: [AccessD] Form Lifetime Control Limit (Was: Advice on > A2010....) > > > > > William Benson: > > I would love to hear MS's defense of this "lifetime" limitation.... > > > > To answer the first part of your question, it all has to do with default > control names. > > When you insert a control in a form, it is given a default name, like > text10 or label121. The counter that names the controls is the Lifetime > Control Limit counter. Once it hits 754, it gives up. > > The reason for that is name collisions. You can't just reset the counter, > especially when lots of controls on the form have default names. In this > scenario, Access might try to name a new control 'text203', and that name > would already exist. In pathological cases, all possible new names for a > control could already exist, and then you're stuck. > > That is why, in my earlier instructions, I required that you rename all > controls with default number-suffixed names before resetting the counter. > > It was to avoid name collisions. > > So, that is the explanation for the Lifetime Control Limit. Is it stupid? > Yes. Is it lazy? Yes. But it was Microsoft's 'quick and dirty' solution > for what they surely imagined was going to be a rare event. > > -Ken > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com