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
 

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