Gee...I dont feel very silly at all! Trying to use excel
functions in access without even realising! Weird that
its included in access help without mentioning that it
doesnt actually work in access.
Thanks very much for your help Peter and Sco.
Peter, I have downloaded your sample database, and have
used your code to display median, Q1 and Q3 in most of my
existing reports.
The only trouble I have is when I have a report that does
not include any grouping headers. When this is the case I
get error 91. Is there a requirement to have the data
grouped? If so I may need to force some artificail or
meaningless groupings.
Thanks again,
cheers,
Meg
-----Original Message-----
This, or a related question, comes up with monotonous
regularity,
since (as noted in another reply) Access does not have
native
functions for this class of statistics. Some time ago, I
created a
Class to provide the missing functionality. Rather than
upsetting
people by posting what would be an even longer message
and occupying
bandwidth unnecessarily, I have uploaded a zip file to my
business
website. The file contains the Class as a .cls file and a
small
database that demonstrates its use in a report.
The link is
http://www.parish-data.com/data/cumstats.zip
The externally visible Methods of the Class are as
follows:
AddItem(VarValue as Variant) - Adds an value to the
internal list of
values of which the Median, first Decile, or whatever
boundary value
you want will be returned. If you pass AddItem a Null it
will simply
be ignored. The data type (Date, Integer, String, etc.)
of the first
value added to the list is recorded. Subsequent values
added must be
of the same type, or you will get an error box and the
new item will
not be added.
AddItems(VarArray as Variant | VarValue1,
VarValue2,....,VarValueN as
Variants) - Adds multiple values to the list. Accepts
either an Array
containing multiple values or a list of values. This
calls AddItem
internally, so it follows the same rules regarding data
types.
Median - Returns a Variant containing the median value
from the list.
This is written as a Method but can be regarded as a
readonly
Property. If there are less than 2 * BucketSize (see
below) total
values in the list, Median returns Null.
Slice(NSlices as Integer, SliceNumber as Integer) -
Returns a Variant
containing the specified boundary value. This does
quartiles, deciles,
or whatever you want - for the first quartile boundary
value you would
invoke it as Slice(4,1). Median converts internally into
Slice(2,1).
If the number of values in the list divided by NSlices is
less than
than BucketSize (see below), Slice returns Null, as it
does if
SliceNumber>= NSlices, or either argument is <1.
The externally visible Properties of the Class are:
Count - Returns a Long containing the number of values in
the list.
BucketSize - Gets or Sets the integer number of values in
a slice
below which Slice (or Median) will not return a value.
This is
read/write and the default value is 3. The object of this
is to avoid
reporting stupid statistics (like the 4th decile boundary
of a list of
8 values!).
Let me know if you have any problems with it.
On Wed, 30 Jun 2004 17:39:35 -0700, "Meg"
I am trying to use the quartile function in a report
footer to calculate Q1, mediam and Q3 {=quartile
([field],1)}
When the report is opened, access prompts me for the
parameter value 'quartile'. The median function has the
same result, and the report will not preview the last
page
of my report without freezing.
Access help states that 'you may need to install
msowcf.dll' but this is already in place.
Any other suggestions?
Thanks
Meg
Please respond to the Newsgroup, so that others may
benefit from the exchange.
Peter R. Fletcher
----== Posted via Newsfeed.Com - Unlimited-Uncensored-
Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the
World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total
Privacy via Encryption =---
.