Creating statistical function using DCount 
Author Message
 Creating statistical function using DCount

I am not an experienced VBA developer.  I am trying to
create a function that would be used as an expression in a
Group By query that would count the number of instances at
each time that the isAlive value is true.

I attach a csv file with the data that I am using for
testing the function.

The pseudocode statment is as follows:

PAlive
Probability that the AGU is Alive at each simulation time.
Probability [isAlive=True] at each simulationTime.
At each simulationTime, pAlive = (Count(isAlive=True)/Count
(isAlive))

I am using DCount to count the number of instances of
isAlive = True but the same value is being displayed
against each record in the results of the query.

Function pAliveSeaVehicleSensorResults()

    On Error Resume Next
    Dim countPAlive As Double

    countPAlive = DCount
("[isAlive]", "SeaVehicleSensorResults", "[isAlive]
=True") / DCount("[isAlive]", "SeaVehicleSensorResults")

    pAliveSeaVehicleSensorResults = countPAlive

End Function

Can anyone help me correct the function statements?

Alex

  SeaVehicleSensorResults.csv
5K Download


Mon, 28 Jun 2004 00:13:41 GMT  
 Creating statistical function using DCount
Looks like you just forgot the apostrophe around True in test1.  Hope this
helps.

Function pAliveSeaVehicleSensorResults()

    On Error Resume Next
    Dim countPAlive As Double
    Dim test1 As String
    Dim test2 As String

    test1 = DCount("[isAlive]", "SeaVehicleSensorResults", "[isAlive] =
'True'")
    test2 = DCount("[isAlive]", "SeaVehicleSensorResults")

    countPAlive = test1 / test2
    pAliveSeaVehicleSensorResults = countPAlive

End Function


Quote:
> I am not an experienced VBA developer.  I am trying to
> create a function that would be used as an expression in a
> Group By query that would count the number of instances at
> each time that the isAlive value is true.

> I attach a csv file with the data that I am using for
> testing the function.

> The pseudocode statment is as follows:

> PAlive
> Probability that the AGU is Alive at each simulation time.
> Probability [isAlive=True] at each simulationTime.
> At each simulationTime, pAlive = (Count(isAlive=True)/Count
> (isAlive))

> I am using DCount to count the number of instances of
> isAlive = True but the same value is being displayed
> against each record in the results of the query.

> Function pAliveSeaVehicleSensorResults()

>     On Error Resume Next
>     Dim countPAlive As Double

>     countPAlive = DCount
> ("[isAlive]", "SeaVehicleSensorResults", "[isAlive]
> =True") / DCount("[isAlive]", "SeaVehicleSensorResults")

>     pAliveSeaVehicleSensorResults = countPAlive

> End Function

> Can anyone help me correct the function statements?

> Alex



Fri, 02 Jul 2004 06:03:24 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Using a statistical function within a Group by Query

2. DCOUNT divided by DCOUNT

3. Statistical Process Control (SPC) Function

4. Utilizing excel statistical functions

5. Statistical function

6. Statistical functions?

7. Seeking Statistical Functions

8. NORMINV Statistical function

9. VB Statistical function solved

10. VB Statistical function

11. Statistical functions for visual basic

12. Statistical functions in VB ????

 

 
Powered by phpBB® Forum Software