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

Generate Text Boxes 1

Status
Not open for further replies.

kennedymr2

Programmer
May 23, 2001
594
AU

In VB6 i am able to generate a large number of text box's on a form using a text box array...
eg
Private Sub LoadM()
With Mname(0)
GridTop = .Top
GridLeft = .Left
CellHeight = .Height
CellWidth = .Width
.Enabled = False
.Visible = True
End With

For Idx = 1 To (NumCols * Numrows) - 1
Load Mname(Idx)
With Mname(Idx)
.Move GridLeft + ((Idx Mod NumCols) * CellWidth), _
GridTop + ((Idx \ NumCols) * CellHeight)
.Visible = True
.Enabled = False
End With
Next 'Idx
End Sub


BUT in Access this does not work.. as it seems access does not have an array for textbox's etc ...


What i am trying to do is dynamically generate a variable number of text boxes on the run using say

Numrows=20
NumCols=10

I would be happy with say Text0101--- Text0120
Text0201--- Text0220
etc... i realize there would not be an array


Is there a solution in Access

Really appreciate if some help could be offered..

Kennedymr2

 
Majp,

Thanks for you help

It looks like in Access you cannot add controls to an existing form, on the fly...but in vb6 you can...

What i will have to do is create all the textbox's i need on the form and set as hidden ,,then unhide the ones that i need on the fly.

Appreciate your reply...

Regards Kennedymr2
 
It looks like in Access you cannot add controls to an existing form,

Sure you can, but it may be just as easy to have some hidden already. The link shows controls being created on a new form, but any form in design view would work.
 
A starting point:
Me.Controls("Text" & Format(100*intCol+intRow, "0000")).Visible = True

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Majp,

I have had a good look at the link, and i agree that this does create new controls on a new form.
I was trying to add controls dynamically on a form allready loaded... ie (as you can in vb6, using arrays)

Have thought about it, and i can probably get away with using this idea, and create a new form each time...

Thanks for your help, much appreciated.

Regards Kennedymr2
 
Pvh,

Thanks for the code..

I am not sure which way i will actually end up doing this
form...either generating a new form each time, or loading all the fields i will need and then setting hidden/visible..

Its a pity that access does not work exactly the same as vb6...!!!

Appreciate your help

Regards Kennedymr2
 
Majp...

Can now see that you can open form in design mode etc...
did not see this in the first instance...sorry...

All ok now !!!!!!

Thanks again..

Kennedymr2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top