Re: Evaluating Expressions with Variable Field Names



You can use:
Me(strField)
which is a shortcut for:
Me.Controls(strField)

But could be point out that whenever you have repeating fields (such as Pct01, Pct02, ...) it always means you have designed a spread*** and not a database? In a relational database, you would use many *records* in a related table, rather than many repeating fields in one table. Post back if you need more info about that.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Pascal.H" <PascalH@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:FF1EC910-F71F-45E6-B307-EDA8D68CB230@xxxxxxxxxxxxxxxx
I have: a report with 36 fields with similar names. e.g., PCT01, PCT02,
PCT03, ...

I want: to loop through the fields, changing the format to bold if the value
of the field < .5.

Code snipet:
For i = 0 To 36
strField = PCT & IIf(i < 10, "0" & i, i)
If Me.strField / 100 < 0.5 Then
Me.strField.FontWeight = 900
Else
Me.strField.FontWeight = 400
End If
Next i


.