For...next statement to move through list of variables

  • Thread starter Thread starter Dickie Black
  • Start date Start date
D

Dickie Black

Hi,

I'm having trouble with For...Next statements. Is it possible to fill text
label boxes (named box_1_1, box_1_2, box_1_3, box_2_1 etc) using this kind
of code

For example:

Dim i As Integer
Dim j As Integer
Dim ijSession As String
Dim DateVal As Date

DateVal = DateValue(Me.DateBox)

For i = 1 To 5

DateVal = Format(DateAdd("d", i - 1, DateVal), "mm/dd/yy")

For j = 1 To 5

ijBox = "Me.Box_" & i & "_" & j & ".Caption" 'generates the name
of box to be filled

Set rs = rs.Clone
If rs.RecordCount > 0 Then

rs.MoveFirst
ijBox = DateVal & ", " & j 'gives value of 4/9/03, 2 etc
Else: End If

Next j

Hope this is reasonably clear,

Dickie

Next i
 
Dan,

Thanks for that, works like a dream. Will this also work in some way for
variables? (eg str1, str2, str3 etc)

TIA,

Dickie
 
Back
Top