In Access, I am trying to build an Array from a recordset to then write to a table
The table will then be used to export records to Excel to Chart a Frequency Distribution
The recordset (rstHistogram) has one field [PayloadWeight]
The table needs 2 fields:
Fld1 (Category) Fld2 (Sum of all the PayloadWeights in that Category]
eg.
Under 10 0 (records in the recordset)
10 to 20 0 "
20 to 30 5 "
etc. up to 21 categories
Is it possible to build an array with the following syntax?
The code is stopping at the "Sum(" saying variable not defined.
I have tried "(Sum(".
Am I completely on the wrong track?
With rstHistogram
'
If [PayLoadWeight] < 10 Then
aryCategory(1) = Sum(IIf([PayLoadWeight] < 10, 1, 0))
ElseIf [PayLoadWeight] >= 10 And [PayLoadWeight] < 20 Then
aryCategory(2) = Sum(IIf([PayLoadWeight] >= 10 And [PayLoadWeight] < 20, 1, 0))
ElseIf etc.
Appreciate any help.
Thanks
Kayleen
The table will then be used to export records to Excel to Chart a Frequency Distribution
The recordset (rstHistogram) has one field [PayloadWeight]
The table needs 2 fields:
Fld1 (Category) Fld2 (Sum of all the PayloadWeights in that Category]
eg.
Under 10 0 (records in the recordset)
10 to 20 0 "
20 to 30 5 "
etc. up to 21 categories
Is it possible to build an array with the following syntax?
The code is stopping at the "Sum(" saying variable not defined.
I have tried "(Sum(".
Am I completely on the wrong track?
With rstHistogram
'
If [PayLoadWeight] < 10 Then
aryCategory(1) = Sum(IIf([PayLoadWeight] < 10, 1, 0))
ElseIf [PayLoadWeight] >= 10 And [PayLoadWeight] < 20 Then
aryCategory(2) = Sum(IIf([PayLoadWeight] >= 10 And [PayLoadWeight] < 20, 1, 0))
ElseIf etc.
Appreciate any help.
Thanks
Kayleen