Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / November 2006

Tip: Looking for answers? Try searching our database.

CreateControl

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Daniel - 20 Nov 2006 04:18 GMT
I use the CreateControl to create a new control within a form.  However,
later I need to reference the newly created control.  How can I name the
control after creating it or is there an input for this that I missed for
this exact purpose?

Thank you,

Daniel
Daniel - 20 Nov 2006 04:26 GMT
I found my answer.  

   Dim ctl As Control
   Set ctl = CreateControl(strDfltName, acTextBox, _
               acDetail, , "Key", 100, 100, 1000, 300)
       'Set Control properties
   ctl.Name = "txtKey"
   Set ctl = Nothing

> I use the CreateControl to create a new control within a form.  However,
> later I need to reference the newly created control.  How can I name the
[quoted text clipped - 4 lines]
>
> Daniel
Klatuu - 20 Nov 2006 14:39 GMT
Creating controls programmatically has to be done with caution.  If this is a
"one time" thing to modify a form, then there should be no problem; however,
if this is a normal part of your processing, be aware there is a "Life Time"
limit of 754 controls on a form. By that, I mean that each time you add a
control, the count goes up by one, but deleteing a control does not subract
from the count.  The end result is that after a period of time, your form
will no longer be usable.

> I found my answer.  
>
[quoted text clipped - 13 lines]
> >
> > Daniel
Daniel - 20 Nov 2006 20:54 GMT
Klatuu,

That should not present a problem for my current application (1 time deal).  
However, is there a way to determine the current lifetime count of a form
through vba?  Not that is crucial, but is there a reason for this limit?  
There is not way to reset the lifetime counter?

Thank you for the heads up, definetly something to keep in mind.  I have a
few forms that have been rework tremendously, this may end up posing a
problem down the line.

If a form get to that point, can one simply create a new form and copy over
all the controls to start anew?

Daniel

> Creating controls programmatically has to be done with caution.  If this is a
> "one time" thing to modify a form, then there should be no problem; however,
[quoted text clipped - 21 lines]
> > >
> > > Daniel
Douglas J. Steele - 20 Nov 2006 21:04 GMT
There's no way to determine the current lifetime count that I'm aware of,
nor any way to reset the counter (other than copying the form and creating a
new object).

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Klatuu,
>
[quoted text clipped - 46 lines]
>> > >
>> > > Daniel
Klatuu - 20 Nov 2006 21:22 GMT
I don't know what the reason is.  It probably relates to some internal limit
Access uses to store information on the objects in the database.
I don't know if there is a way to know the lifetime count.  You can find the
number of current controls if the form is open using:
Forms!TheFormName.Controls.Count

You can copy the form to a new mdb and it will loose the lifetime count.

> Klatuu,
>
[quoted text clipped - 37 lines]
> > > >
> > > > Daniel
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.