I have a large quantity of textboxes that need to be filled with the results of SQL statements. I would like to use a for loop to do this but I am unable to successfully integrate a variable in my form control reference. the code shown below errors out at the last line of the second for loop stating that there is no such form control named 'LetterStrategy_BalanceTo & (x)'.
Code:
Dim SQL_LetterStrategy_BalanceToArray(1 To 9)
For x = 1 To 9
SQL_LetterStrategy_BalanceToArray(x) = " SELECT Top 1 BalanceTo" & x & " FROM" _
& " [Letter_Strategy] WHERE Client ='" & Client & "'" & " ORDER BY [EffectiveDate] DESC;"
Next x
For x = 1 To 9
Set rs = db.OpenRecordset(SQL_LetterStrategy_BalanceToArray(x), dbOpenDynaset)
Dim LetterStrategy_BalanceToArray(1 To 9)
LetterStrategy_BalanceToArray(x) = rs.Fields("BalanceTo" & x)
Forms![Strategy Binder]![LetterStrategy_BalanceTo & (x)] = LetterStrategy_BalanceToArray(x)
Next x
It may just be an issue of syntax. Any help would be appreciated.