Array of Labels

J

Jan Pit

Is is possible to have an array of labels in a report?
This would allow me to have in VB a statement like:
for nItm = 1 to 40
Me!LblArray(nItm).Caption = aItm(nItm)
next
Now I have instead to enter for each label a separate line.
Any nice ideas welcome.

+ Jan Pit +
Botswana
 
A

Allen Browne

You cannot make an array of controls, but you can refer to the controls in
the loop if the have the right names. This example assumes labels named
LblArray1, LblArray2, ... LblArray40.

Dim strControl As String
Dim nItem As Integer

For nItem = 1 to 40
strControl = "LblArray" & nItem
Me(strControl).Catpion = aItm(nItem)
Next
 
J

Jan Pit

Bright! Great answer. Thanks.

+ Jan +
Allen Browne said:
You cannot make an array of controls, but you can refer to the controls in
the loop if the have the right names. This example assumes labels named
LblArray1, LblArray2, ... LblArray40.

Dim strControl As String
Dim nItem As Integer

For nItem = 1 to 40
strControl = "LblArray" & nItem
Me(strControl).Catpion = aItm(nItem)
Next
 
Top