Allen said:
You should also know that the Decimal field type is very poorly implemented
in Access. Even basic sorting fails. More info:
http://allenbrowne.com/bug-08.html
Hmm, more like 'obscure engine-side sorting fails' i.e. the data must
contain negative values, the sort order must be descending and the
sorting must be done by the engine.
Following your link:
AllenB: "If the [column] is a Decimal type and you ask for descending
order, the sorting is wildly inaccurate...Negative values appear first
(wrong), followed by the positive ones. Nulls and zeros sort
unpredictably - at the beginning, middle or end, depending on the
data."
'Wildly inaccurate' is a bit emotive when you consider the pattern is
entirely predictable.
Yes, the sort order is wrong: first (wrong) the negative (less than
zero) values are correctly sorted in descending order, then positive
values (greater or equal to zero) correctly sorted in descending order,
last (correct) the NULL values.
In my tests, NULL values and zeros always sort predictably. In fact,
the Jet 4.0 spec for collation means NULLs will *always* appear last.
If you can post some code where the engine does not sort NULLs to the
end of the resultset then *that* would be news.
Now we've established the problem, the workaround is simple: do the
sorting in the middleware. For example, you could do the sort in the
recordset:
rs.Sort = "decimal_col DESC"
Jamie.
--