Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic text boxes

Status
Not open for further replies.

bronc

Instructor
Aug 28, 2003
145
GB
Hello: I would like to dynamically place some text boxes on a form at run time.
 
Have a look at the CreateControl method.
 
well thanks , i have not seen CreateControl before but it appears to only make a control at design time.

i have used code like this :

Dim objEvents As New Collection
Dim objNew As clsBtn 'clsBtn is the nam of the class
Set objNew = New clsBtn
Set objNew.objTxt = frmData.Controls.Add("Forms.TextBox.1")
With objNew.objTxt
'etc
objEvents.Add objNew
'etc

but this is for a user form (in Word) and would like to do the same in Access.
 
You will find CreateControl in Access vba help.


It will only work in design view.

What were your reasons for wishing to create a control? It should not be necessary in a properly designed live database.
 
well i wish to have a command button on the form so that when i press it a new text box appears. (I don't want to workaround using a visible true/false.)
 
Setting visible true / false is not generally considered to be a 'work-around'. Adding controls at run-time is problematical, to say the least; if you take this path you will not be able to make an mde to protect your code, to mention just one problem. I suggest you use visible true / false.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top