T
TKD Karen
I wrote this function (below) that is called 3 times; one for each case
scenario. But the function only works for the Unresolved, not for the other
2 cases. There doesn't seem to be anything wrong with the strSQL statement
because if I put it into an Access query design, I get results for all 3
values. But when I run it (unresolved is the last one called, btw), Admin
and Fraud are coming up Null. Any ideas what the problem is?
Private Function GetTotalAvg(strWhichAvg As String) As Single 'for ADO only
works for Unresolved, not for Admin or Fraud
Dim strSQL As String
Dim rsAverages As ADODB.Recordset
Set rsAverages = New ADODB.Recordset
strSQL = "SELECT Avg(FraudDaysTaken) as AvgOfFraudDaysTaken, " _
& "Avg(AdminDaysTaken) as AvgOfAdminDaysTaken,
Avg(UnResolvedDaysTaken) as " _
& "AvgOfUnresolvedDaysTaken FROM qryAFIS_QtrResolDates"
rsAverages.Source = strSQL
rsAverages.Open , CurrentProject.Connection
Select Case strWhichAvg
Case "Unresolved"
GetTotalAvg = Nz(rsAverages!AvgOfUnResolvedDaysTaken, 0)
Case "Fraud"
GetTotalAvg = Nz(rsAverages!AvgOfFraudDaysTaken, 0)
Case "Admin"
GetTotalAvg = Nz(rsAverages!AvgOfAdminDaysTaken, 0)
End Select
rsAverages.Close
Set rsAverages = Nothing
End Function
--
Karen Stern
A Little Help Computer Services, LLC
www.alittlehelp.net
(e-mail address removed)
518-885-4549
Everyone Needs A Little Help!
scenario. But the function only works for the Unresolved, not for the other
2 cases. There doesn't seem to be anything wrong with the strSQL statement
because if I put it into an Access query design, I get results for all 3
values. But when I run it (unresolved is the last one called, btw), Admin
and Fraud are coming up Null. Any ideas what the problem is?
Private Function GetTotalAvg(strWhichAvg As String) As Single 'for ADO only
works for Unresolved, not for Admin or Fraud
Dim strSQL As String
Dim rsAverages As ADODB.Recordset
Set rsAverages = New ADODB.Recordset
strSQL = "SELECT Avg(FraudDaysTaken) as AvgOfFraudDaysTaken, " _
& "Avg(AdminDaysTaken) as AvgOfAdminDaysTaken,
Avg(UnResolvedDaysTaken) as " _
& "AvgOfUnresolvedDaysTaken FROM qryAFIS_QtrResolDates"
rsAverages.Source = strSQL
rsAverages.Open , CurrentProject.Connection
Select Case strWhichAvg
Case "Unresolved"
GetTotalAvg = Nz(rsAverages!AvgOfUnResolvedDaysTaken, 0)
Case "Fraud"
GetTotalAvg = Nz(rsAverages!AvgOfFraudDaysTaken, 0)
Case "Admin"
GetTotalAvg = Nz(rsAverages!AvgOfAdminDaysTaken, 0)
End Select
rsAverages.Close
Set rsAverages = Nothing
End Function
--
Karen Stern
A Little Help Computer Services, LLC
www.alittlehelp.net
(e-mail address removed)
518-885-4549
Everyone Needs A Little Help!