Article ID: 210581 - View products that this article applies to.
This article was previously published under Q210581
Advanced: Requires expert coding, interoperability, and multiuser skills.
This article applies only to a Microsoft Access database (.mdb).
This article shows you how to create a Visual Basic for Applications procedure to open a table, read the data, and find the statistical median. The median is a measure of central tendency, another "middle" measurement 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].
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure. However, they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. Note The sample code in this article uses Microsoft Data Access Objects. For this code to run correctly, you must reference the Microsoft DAO 3.6 Object Library. To do so, click References on the Tools menu in the Visual Basic Editor, and make sure that the Microsoft DAO 3.6 Object Library check box is selected. To create a procedure that determines the statistical median of a set of numbers, follow these steps:
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:
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: