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!

LOADING TEXT BOXES AT FORM LOAD EVENT

Status
Not open for further replies.

TNN

Programmer
Sep 13, 2000
417
US
Using the following code:

Private Sub Form_Load
dim i as integer
for i = 1 to 7
load txt1(i)
txt1(i).left = txt1(i-1).left + txt1(i-1).width
txt1(i).top = txt1(i-1).top
txt1(i).visible = true
next i
end sub

I am trying to load 20 rows of text boxes loading 7 text boxes per row. The first column of boxes are already on the form (8 boxes per row). Each row of boxes is an array 0 thru 7. I can load the first row but can't figure out how to load the succeding rows whose text boxes start with
txt2(0), txt3(0), txt4(0), etc. In the code I have to change txt1 to txt2 etc. I am trying to avoid having to write this code for each row but instead iterate thru txt1, txt2, etc. But How??

Any help is appreciated.

Thank You,
TNN, Tom
TNPAYROLL@AOL.COM
[sig]<p>TOM<br><a href=mailto:WWW.TNPAYROLL@AOL.COM>WWW.TNPAYROLL@AOL.COM</a><br>[/sig]
 
hi tom,

don't *think* you can do that --- you sure you can't create them all in the same control array? [sig]<p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>Making mistakes, so you don't have to. &lt;grin&gt;[/sig]
 
Hi Mike
If I use a single control array then when I load up the text boxes from a recordset my code will be 20 times larger and hard to read. I will have to think about this some more.

My code to fill text boxes from a recordset:
set txt1(0).datasource = rst
txt1(0).datafield = &quot;name&quot;
And so on to fill the 8 text boxes in the first row of 20 rows.

Any other ideas out there are welcomed.

Thank You,
TNN, Tom
TNPAYROLL@AOL.COM [sig]<p>TOM<br><a href=mailto:WWW.TNPAYROLL@AOL.COM>WWW.TNPAYROLL@AOL.COM</a><br>[/sig]
 
Hi, this may not be perfect but just an idea i think you can use this: please check the syntax please

for i = 0 to form.controls.count - 1
if typeof control is text then
if counter > 8 then
exit sub
else
if control name = txt & counter then
---
' your for loop goes here
---
counter=counter + 1
end if
end if
end if
next


hope this will help u solve your problem or atleast give you new idea. Will you please let me know the solution once you get it. please mail to gantibabu@yahoo.com. all the best...vijay [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top