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

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
 
D

Dickie Black

Dan,

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

TIA,

Dickie
 

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