Referencing Unbound fields with variables
I have 10 fields on a subform, named TP1, TP2, .... thru TP10.
I want to sum the value of each of the 10 fields.
I would like to use a loop to do this, like the following:
Dim p As Integer
Dim PalletCount As Single
For p = 1 To 10
PalletCount = PalletCount + Eval("TP" & p & ".Value")
Debug.Print PalletCount
Next p
I get the message "Microsoft Access can't find the name 'TP1' you entered in the expression.
I would like to avoid the following more explicit method:
PalletCount = TP1 + TP2 + TP3 + TP4 + TP5 .... + TP10
|