i have an array(9) and want to fill corresponding txtboxes so that array(0) fills txtbox0, array(1) fills txtbox1, array(2) fills txtbox2. is there a way to do this with a loop?
Dim intCounter as integer
For intCounter = 0 to 9
txtbox(intCounter).text = array(intCounter + 1).text
Next intCounter HTH,
Randy Smith
California Teachers Association
First of all, I'm glad to see I'm not the only one that is looking on multiple websites for help (saw the same post on dbforums.com). Here's the same answer I posted there:
[tt]
For i = 0 To 9 Step 1
Controls("txt" & i).value = myarray(i)
Next i [/tt]
I don't think Randy's code will work in VBA. For some reason Micro$oft decided not to allow control arrays in VBA so you cant just name it txtbox(int). Thankfully there is a way around it.. just not as neat looking. -Dustin
Rom 8:28
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.