Help!
I have a query with enumerated field names (i.e. CBL_1_kW,CBL_2_kW,CBL_3_kW,......CBL_10_kW)
I'm trying to construct the field names with a counter and feed them into an array where I can sort them later. (i.e. rs!["CBL_"& Str(i) & "_kW")
The problem I am having is that the program fails to compile when the field name is constructed in the for loop with the counter (i). If I manually type in the variable it works find but this is tedious and poor programming I would think.
Any advice?
----------------------
type MeterReading
Date as variant
kW as variant
end type
dim MeterReadings(1 to 10) of MeterReading
rs.movefirst
do while not (rs.eof)
for (i=1 to 10)
with MeterReadings(i)
.Date = rs!["CBL_"&Str(i)&"_Date"] <--- compile error
.kW = rs!["CBL_"&Str(i)&"_kW"] <---- compile error
end with
next i
rs.movenext
loop
I have a query with enumerated field names (i.e. CBL_1_kW,CBL_2_kW,CBL_3_kW,......CBL_10_kW)
I'm trying to construct the field names with a counter and feed them into an array where I can sort them later. (i.e. rs!["CBL_"& Str(i) & "_kW")
The problem I am having is that the program fails to compile when the field name is constructed in the for loop with the counter (i). If I manually type in the variable it works find but this is tedious and poor programming I would think.
Any advice?
----------------------
type MeterReading
Date as variant
kW as variant
end type
dim MeterReadings(1 to 10) of MeterReading
rs.movefirst
do while not (rs.eof)
for (i=1 to 10)
with MeterReadings(i)
.Date = rs!["CBL_"&Str(i)&"_Date"] <--- compile error
.kW = rs!["CBL_"&Str(i)&"_kW"] <---- compile error
end with
next i
rs.movenext
loop