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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding new text boxs to a form with VB

Status
Not open for further replies.

joebickley

Programmer
Aug 28, 2001
139
GB
I want to add text boxes to a form depending on the data that is sent to it. I can create a text box in code but how do i get it to display

any help would be great thanks
 
Have you set the size of the control properly and made sure that the control is visible? Another apporach might be to create the controls on the form manually, placing them exactly where you want and only showing them when required. Here's an example of what you are looking to do that I grabbed from the MS-Access help.

Sub NewControls()
Dim frm As Form
Dim ctlLabel As Control, ctlText As Control
Dim intDataX As Integer, intDataY As Integer
Dim intLabelX As Integer, intLabelY As Integer

' Create new form with Orders table as its record source.
Set frm = CreateForm
frm.RecordSource = "Orders"
' Set positioning values for new controls.
intLabelX = 100
intLabelY = 100
intDataX = 1000
intDataY = 100
' Create unbound default-size text box in detail section.
Set ctlText = CreateControl(frm.Name, acTextBox, , "", "", _
intDataX, intDataY)
' Create child label control for text box.
Set ctlLabel = CreateControl(frm.Name, acLabel, , _
ctlText.Name, "NewLabel", intLabelX, intLabelY)
' Restore form.
DoCmd.Restore
End Sub

 
I usually create the text box in form design and then set the visible property to yes or no depending on my conditions.

If (Logical statement) then
me.txtConditional.visible = True
Else
me.txtConditional.visible = False
End If

Tyrone Lumley
augerinn@gte.net


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top