How fill 30 report controls from a string

M

mscertified

The query that feeds my report passes a character string of 2-byte numbers;
these must be moved into report heading controls. E.g.
String 010203040506 must become
01 02 03 04 05 06
The heading controls are named H1 thru H30
To do this, I attempted to use EVAL("H" & i) = xx
in a loop, varying i, but this does not seem to work.

Is there another way other than hardcoding each 30 moves in an IF ..ELSE.
The other catch is I need to make the controls invisible if they are not
filled, i.e. if only 20 numbers are passed, I need to make the last 10
controls invisible.

Any help appreciated.
 
A

Allen Browne

This example assumes the 30 controls are labels named H0 to H29:

Dim i As Integer
Dim iLen as Integer
iLen = Len(strIn)
For i = 0 to 29 \ 2 Step 2
If i < iLen Then
With Me.Controls("H" & i)
.Caption = Mid(strIn, i + 1, 2)
.Visible = True
End With
Else
Me.Controls("H" & i).Visible = False
End If
Next

That's aircode that will going to need some debugging (such as loop
termination), but hopefully it's enough to set you on the track.
 

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