Frankenstein Text Boxes

  • Thread starter Thread starter Bill (Unique as my name)
  • Start date Start date
B

Bill (Unique as my name)

I have a blank form. My interest is threefold: 1) I want to create
textboxes, 2) to be able to change the name of the text boxes, 3) to
change their location on the form.

I have a form with 420 unbound textboxes. When the form opens, a VBA
function runs a loop with three lengthy lines, each with its own
monstrous dlookup statement, which determines the values of the forms
textboxes. It took a while to set up the textboxes on the form and to
rename them so that the VBA function would work. The VBA part was a
breeze once Doug and others helped me with the code syntax.

Now I want to be brave and bold.

All I need is a single example that creates a textbox, gives it a name,
and sets some standard property values and the location. That would be
wonderful. Or if you have some handy links, that also would be a
blessing.

I've looked around and found a message which shows how to create a form
in VBA and save it. But for the present, I just want to know about
textboxes.

Thank you! Thank you! Thank you! Thank you! Thank you! Thank you!
Thank you!
 
I have a blank form. My interest is threefold: 1) I want to create
textboxes in VBA, 2) to be able to change the name of the text boxes in
VBA, 3) to change their location on the form in VBA.

I have a form with 420 unbound textboxes. When the form opens, a VBA
function runs a loop with three lengthy lines, each with its own
monstrous dlookup statement, which determines the values of the forms
textboxes. It took a while to set up the textboxes on the form and to
rename them so that the VBA function would work. The VBA part was a
breeze once Doug and others helped me with the code syntax.


Now I want to be brave and bold.


All I need is a single example that creates a textbox, gives it a name,
and sets some standard property values and the location. That would be
wonderful. Or if you have some handy links, that also would be a
blessing.


I've looked around and found a message which shows how to create a form

in VBA and save it. But for the present, I just want to know about
textboxes.


Thank you! Thank you! Thank you! Thank you! Thank you! Thank you!
Thank you
 
All I need is a single example that creates a textbox, gives it a name,
and sets some standard property values and the location. That would be
wonderful. Or if you have some handy links, that also would be a
blessing.

Bill,

Here is what I used to dynamically create my textboxes:
*****
Dim fld as DAO.Field
Dim TempHoldingRS as DAO.Recordset
Dim frm as Form

'frm is created dynamically, assumes the name "Form1"
'Since you found form creating code, I will omit

'Looks at the fields in the holding table and creates a form based on those
fields
For Each fld In TempHoldingRS.Fields
With CreateControl(frm.Name, ControlType:=acTextBox, _
Section:=acDetail, Parent:="", Columnname:=fld.Name, _
Left:=intNewLeft, Top:=0)
.Name = fld.Name
intNewLeft = intNewLeft + .Width
.Locked = True
.Enabled = False
End With
Next fld

*****
I think this is what you are looking for, if I understood correctly.

Hope it helps :)

-Nick
 
Thanks for the kind assistance, Nick.
Bill,

Here is what I used to dynamically create my textboxes:
*****
Dim fld as DAO.Field
Dim TempHoldingRS as DAO.Recordset
Dim frm as Form

'frm is created dynamically, assumes the name "Form1"
'Since you found form creating code, I will omit

'Looks at the fields in the holding table and creates a form based on those
fields
For Each fld In TempHoldingRS.Fields
With CreateControl(frm.Name, ControlType:=acTextBox, _
Section:=acDetail, Parent:="", Columnname:=fld.Name, _
Left:=intNewLeft, Top:=0)
.Name = fld.Name
intNewLeft = intNewLeft + .Width
.Locked = True
.Enabled = False
End With
Next fld

*****
I think this is what you are looking for, if I understood correctly.

Hope it helps :)

-Nick
 
Back
Top