SQL Statement in error?

NJudson

Who farted?
Local time
Today, 13:16
Joined
Feb 14, 2002
Messages
297
I want to output the results of an SQL statement into a listbox on my form and when I run it the listbox is just blank. Can someone take a look at my SQL for any errors or if there may be a common mistake that I may be making in setting up my listbox? The SQL looks like this:

Me.ListAverage.RowSource = "SELECT SUM([Totals2].[RBER Drop Attempts/Call Volume]) AS [SumOfRBER Drop Attempts/Call Volume], " & _
"COUNT([Totals2].[RBER Drop Attempts/Call Volume]) AS [Totals2].[CountOfRBER Drop Attempts/Call Volume], " & _
"([SumOfRBER Drop Attempts/Call Volume]/[CountOfRBER Drop Attempts/Call Volume])*100 AS Average INTO AverageRBER " & _
"FROM Totals2 " & _
"WHERE [Totals2].[Cell-ID] = '" & Me.ListTotals & "' " & _
"And [Totals2].[Switch] = '" & SWITCH & "' " & _
"GROUP BY [SumOf RBER Drop Attempts/Call Volume]/[CountOfRBER Drop Attempts/Call Volume])*100;"


basically the SQL is trying to take the (Sum(Field1)/Count(Field1))*100 which as we all know = Average and it's this average that I want to display in my listbox on the form but it's not working. Is there a specific format that I need to setup my listbox as?
Thanks.
 
I can't comment on why your code doesn't work; but here's a suggestion that might help you out.

Create a saved query that calculates the average values you want in your list box.

Next, use a simple SQL statement (in the row source in your list box) to select the average field from your query.

SELECT [Average] FROM [my_query]

This should give you the results you want.
 
You should also not use reserved words for field names, Switch is a reserved word in access.
 

Users who are viewing this thread

Back
Top Bottom