loop problem

B

Boots

Hi,
I am trying to create a loop to help format a report. On the report I
have 52 fields named TimeSeg1.....to......TimeSeg52.
My loop has to format each Field into a certain colour depending on its
value. I have created a Do While loop with the theory that I can use the
following
--------------------------------------------------------------------------------------
dim ts as ? (i have tried string, control and field)
dim lp as integer
lp = 1

ts = ("Me.TimeSeg" & lp)
Do while (lp < 53)

LOOP CRITERIA to format field

lp = lp +1
loo
 
D

Douglas J. Steele

I'll ignore the fact that your table isn't normalized. <g>

Just to be precise with terminology, you're trying to format controls on the
report, not fields: fields are what's in the recordsource, and they simply
contain values.

I find it helps to rename the controls from the default name Access gave
them. (For some unknown reason, Access insists on naming the controls the
same as the fields to which they're bound.) Let's assume that you have 52
text boxes on your report named txtTimeSeg1 to txtTimeSeg52.

Try:

Dim ts As Control
Dim lp As Integer

lp = 1
Do While (lp < 53)
Set ts = Me.Controls("txtTimeSeg" & lp)
' format control "ts"
ts.BackColor = ....
lp = lp +1
Loop
 
B

Boots

Thanks very much

Douglas J. Steele said:
I'll ignore the fact that your table isn't normalized. <g>

Just to be precise with terminology, you're trying to format controls on the
report, not fields: fields are what's in the recordsource, and they simply
contain values.

I find it helps to rename the controls from the default name Access gave
them. (For some unknown reason, Access insists on naming the controls the
same as the fields to which they're bound.) Let's assume that you have 52
text boxes on your report named txtTimeSeg1 to txtTimeSeg52.

Try:

Dim ts As Control
Dim lp As Integer

lp = 1
Do While (lp < 53)
Set ts = Me.Controls("txtTimeSeg" & lp)
' format control "ts"
ts.BackColor = ....
lp = lp +1
Loop
 

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