Jeff,
The problem I am having with creating a query is that txtOldNum is a
product
of making a selection from the combo box [cboBMNUM]:
SELECT PtblBenchmark.OBJECTID, PtblBenchmark.BMNum, PtblBenchmark.Name,
PtblBenchmark.Elevation, PtblBenchmark.st_name_1, PtblBenchmark.st_name_2
FROM PtblBenchmark;
[txtOldNum]=cboBMNUM.column(3) {PtblBenchmark.Elevation}
From my experience .column() does not work in a query. Is there a way to
fake this? Because, technically, [txtOldNum] does not exist until a
selection is made from the combo box in the form (as a calculated value).
All the other values are easily done with an expression in the query. I
understand that Access does not like to calculate values in a form based
on
calculated values from the form. I guess I could add a field to store the
value of txtOldNum, I was just trying to follow the rules of normalization
by
not storing values that didn't need stored.
Which brings us back to the original issue:
As I enter records into the subform in question, how do I get a running
average over [txtNumDiff] (in the subform footer) excluding the rows where
[txtNumDiff] equals zero.
Thanks,
NickX
Jeff Boyce said:
Nick
A query works with data from a table (or another query). It doesn't work
with data from a form (mainly because the data isn't really "in" the
form,
it's in the underlying table(s)).
Try creating a query against the original data tables instead of the
form.
Regards
Jeff Boyce
Microsoft Office/Access MVP
Jeff,
Thanks for your response.
[txtNumAvg]=IIf([NewNum2]=0,[NewNum1],([NewNum1]+[NewNum2])/2)
I moved this to the query as an expression.
what I want is the difference between [txtOldNum] and [txtAvgNum]
([txtNumDiff]) to be averaged across the whole subform dataset
(ignoring
zeros) and resulting in [txtRunningAvg]
cboBMNUM|txtbox|txtOldNum|NewNum1|NewNum2|txtNumAvg|txtNumDiff
cbox column(1)|(2) |(3)
1328 |` |.000 |735.91 |0.00 |735.91 |N/A
219 |` |745.210 |744.18 |0.00 |744.18 |1.0270
1329 |` |.000 |738.71 |0.00 |738.71 |N/A
240 |` |753.790 |753.01 |0.00 |753.01 |0.7760
287 |` |830.180 |829.41 |0.00 |829.41 |0.7690
980 |` |.000 |758.46 |0.00 |758.46 |N/A
679 |` |749.520 |748.67 |0.00 |748.67 |0.8460
the last column [txtNumDiff] averages out to be 0.8545 or 3.418 divided
by
4,
how would I display this in the subform footer?
Thanks,
NickX
PS: (cbox column(1)|(2)|(3) is an illustration of [cboBMNUM] to show
where
txtOldNum is drawn from)
:
Consider using a query, doing the comparison between 1 & 2 there, and
excluding the record if they are equal (i.e., difference = 0).
Regards
Jeff Boyce
Microsoft Office/Access MVP
Hi all,
I have a subform that has several calculated values, the last of
which
is
the difference.
[txtOldNum]=cboBMNUM.column(3)
[NewNum1] is bound
[NewNum2] is bound
[txtNumAvg]=IIf([NewNum2]=0,[NewNum1],([NewNum1]+[NewNum2])/2)
[txtNumDiff]=IIf([txtOldNum]=0,"N/A",[txtOldNum]-[txtNumAvg])
I would like to get the running average of [txtNumDiff]
[txtRunningAvg]=Avg([txtNumDiff]) where [txtNumDiff] rows that equal
0
are
excluded from the calculation.
Thanks,
NickX