473,396 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Stupid Error that I'm not seeing?

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
ks****@alittlehelp.net
518-885-4549
Everyone Needs A Little Help!
Jul 17 '05 #1
2 1814
"TKD Karen" <ks****@alittlehelp.net> wrote in message news:<F1******************@twister.nyroc.rr.com>.. .
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?


I don't see anything obviously wrong. Your select is case-sensitive
so if you are asking for "fraud" you won't get it but other than that
it looks fine. Have you stopped the code in VB to see if you are
getting values for all 3 returned?

FWIW, I probably would have written it a little differently:

Private Function GetTotalAvg(ByVal WhichAvg As String) As Single
Dim strSQL As String
Dim rsAverages As ADODB.Recordset
Select Case lcase$(WhichAvg)
case "Admin","Fraud","Unresolved":
strSQL = "SELECT Avg(" & WhichAvg & "DaysTaken) As AvgDays " & _
"FROM qryAFIS_QtrResolDates"
Set rsAverages = CurrentProject.Connection.Execute(strSQL)
If Not rsAverages.EOF Then
If Not IsNull(rsAverages.Fields("AvgDays").Value) Then
GetTotalAvg = rsAverages.Fields("AvgDays").Value
End If
End If
Set rsAverages = Nothing
End Select
End Function
Jul 17 '05 #2
Thanks, I'll try it your way. I was stepping through my code and the fields
in the recordset for fraud and admin were coming in as Null, but they should
have values and do when I use the sql string as a query. The function has
worked in similar situations, just not this particular one. Oh well.
Thanks for the advice!

"Bob Butler" <bu*******@earthlink.net> wrote in message
news:fa*************************@posting.google.co m...
"TKD Karen" <ks****@alittlehelp.net> wrote in message

news:<F1******************@twister.nyroc.rr.com>.. .
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?


I don't see anything obviously wrong. Your select is case-sensitive
so if you are asking for "fraud" you won't get it but other than that
it looks fine. Have you stopped the code in VB to see if you are
getting values for all 3 returned?

FWIW, I probably would have written it a little differently:

Private Function GetTotalAvg(ByVal WhichAvg As String) As Single
Dim strSQL As String
Dim rsAverages As ADODB.Recordset
Select Case lcase$(WhichAvg)
case "Admin","Fraud","Unresolved":
strSQL = "SELECT Avg(" & WhichAvg & "DaysTaken) As AvgDays " & _
"FROM qryAFIS_QtrResolDates"
Set rsAverages = CurrentProject.Connection.Execute(strSQL)
If Not rsAverages.EOF Then
If Not IsNull(rsAverages.Fields("AvgDays").Value) Then
GetTotalAvg = rsAverages.Fields("AvgDays").Value
End If
End If
Set rsAverages = Nothing
End Select
End Function

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: | last post by:
I am accessing the same error-containing ASP page on an ISP server using w2k IE6 but with different effect. On the first computer I get several line of HTML outputed by ASP, shown correctly by...
38
by: Shaun McKinnon | last post by:
HI...Here's my problem...I have a popup window that loads when i want it to, but it's not sized properly. I've set the size, but it doesn't seem to work. I've been on 8 different websites to find...
3
by: João Santa Bárbara | last post by:
Hi all. i have a funny error in the IDE but only in one form. :( i have declare a Method like this "Private Sub MyTransGForms(ByVal sender As Object, ByVal e As EventArgs)" and i have an...
119
by: rhat | last post by:
I heard that beta 2 now makes ASP.NET xhtml compliant. Can anyone shed some light on what this will change and it will break stuff as converting HTML to XHTML pages DO break things. see,...
2
by: Lampa Dario | last post by:
Hi, where is this stupid error in this program? When I execute it, i receive a segmentation fault error. #include <stdio.h> int main(int argc, char *argv, char *env) { int i=0; int l=0; int...
4
by: tommy | last post by:
hello everbody, i write a little asp-application with forms-authentication. i copy my aspx-files with web.config to my webspace and i get the error above... i tried to set the...
3
by: Ramesh Dodamani | last post by:
Environment: XP Pro, VS.Net 2003, .Net 1.1.4322 with SP1 & KB Hotfix 886903 P4 2.2GHz, 1 GB RAM My system was working fine till a few weeks back when I started seeing the following errors. ...
15
by: sparks | last post by:
We get more and more data done in excel and then they want it imported into access. The data is just stupid....values of 1 to 5 we get a lot of 0's ok that alright but 1-jan ? we get colums...
2
by: Ike | last post by:
Im wondering if someone can take a look at this simple INSERT statement which is puking on me. I KNOW I must have something stupid in it that I am NOT seeing, which will likely be obvious to...
3
by: jschvat | last post by:
I get the following output in vs2005: 'AllocationTest.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded. Detected memory leaks! Dumping objects -> {263} normal block at...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.