Indirect reference to tex boxes in a form

C

Cesar

I have a form with 288 text boxes arranged in 24 columns with 12 rows each.
I need to enter values from a matrix on each one of these text boxes.
Is there a way to reference each text box other than using its name?
The idea is to use a matrix to indirectly reference each text box insted of
programming 288 lines of code, one for each text box.
 
J

John Spencer

The best you could do would be to Set up the names of the controls something
like
txtControl0101
txtControl1201
txtControl2412

Then you could refer to the controls by name using something like

For i = 1 to 24
For ii = 1 to 12
Me(txtControl & Format(i,"00") & Format(ii,"00")) = arr(i, ii)
Next ii
Next i

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
C

Cesar

Excellent!
Since the cells were named Text1_1 through Text24_15, the actual code that
worked is:

Private Sub FillCells()
x = 0
Do While x < 15
x = x + 1
y = 0
Do While y < 24
y = y + 1
BenefitsSubFrm("Text" & Format(Str(y), "#0") & "_" &
Format(Str(x), "#0")) = IIf(CellValue(x, y) = 0, "", CellValue(x, y))
Loop
Loop
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top