The following example returns estimates of the variance for a population and a population sample for orders shipped to the United Kingdom. The domain is an Orders table. The criteria argument restricts the resulting set of records to those for which ShipCountry equals UK.
Dim dblX As Double, dblY As Double
' Sample estimate.
dblX = DVar("[Freight]", "Orders", "[ShipCountry] = 'UK'")
' Population estimate.
dblY = DVarP("[Freight]", "Orders", "[ShipCountry] = 'UK'")
The next example returns estimates by using a variable, strCountry
, in the criteria argument. Note that single quotation marks (') are included in the string expression, so that when the strings are concatenated, the string literal UK
will be enclosed in single quotation marks.
Dim strCountry As String, dblX As Double
strCountry = "UK"
dblX = DVar("[Freight]", "Orders", "[ShipCountry] = '" _
& strCountry & "'")