ACC: How to Use Code to Derive a Statistical MedianLast reviewed: August 29, 1997Article ID: Q95918 |
The information in this article applies to:
SUMMARYAdvanced: Requires expert coding, interoperability, and multiuser skills. This article describes a Visual Basic for Applications procedure that you can use to open a table, read the data, and find the statistical median. The median is a measure of central tendency, another "middle" of a data set, like the mean or average). The data set consisting of the numbers 1, 2, 3, 6, and 100 has a median of 3, the middle of the set. The data set consisting of the numbers 1, 2, 6, and 10 has a median of 4, the middle of the set [(2 + 6) / 2 = 4]. This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual. NOTE: Visual Basic for Applications is called Access Basic in Microsoft Access versions 1.x and 2.0. For more information about Access Basic, please refer to the "Introduction to Programming" manual in Microsoft Access version 1.x or the "Building Applications" manual in Microsoft Access version 2.0.
MORE INFORMATIONTo create a procedure that determines the statistical median of a set of numbers:
How to Use the Median() FunctionCreate a form and add a text box control where you want to display the median values of a data set. Set the ControlSource property of the text box control to the following:
=Median("<TableName>", "<FieldName>")The value of this control is the median of the data set. Another way to use this function is to call it from within another function that compares the median from different data sets. For example,
Function CompareMedians() Dim MyDB as Database . . . X = Median("<TableName>", "<FieldName>") Y = Median("<TableName>", "<FieldName>") If X > Y Then Debug.Print "The median for X is greatest." End Function |
Additional query words: statistics
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |