Ok, so I fixed it, but still not sure why I need a work around in this scenario. I noticed in the query results, this column was left aligned which IIRC indicates its text and not numeric so it was probably giving me the max ascii value? The fields in this table are all set to numbers so it should be giving me numbers in the query? Doing a + 0 gives me what I want.
Sum(MonthSum) + 0 As AvgNum
Pay not attention to the 'AvgNum' naming convention. This is shared with things that use averages.
Code:
Public Function RangeQueryAttendanceSum(ByVal strField As String) As String
RangeQueryAttendanceSum = _
"SELECT tblAgents.ID As AgentID, Sum(MonthSum) + 0 As AvgNum, " & lstMonths.ItemsSelected.Count & " As NumRecords" & vbCrLf & _
"FROM tblAgents" & vbCrLf & _
"LEFT JOIN (" & vbCrLf & _
"SELECT tblAttendance.AgentID As AgentID, Sum(" & strField & ") As MonthSum, Count(*) As NumErrorRecords" & vbCrLf & _
"FROM tblAttendance" & vbCrLf & _
"WHERE tblAttendance.RepType=" & cmbRepType & " AND " & BuildMonthCondition() & vbCrLf & _
"GROUP BY tblAttendance.AgentID" & vbCrLf & _
") As GetAttendance" & vbCrLf & _
"ON tblAgents.ID=GetAttendance.AgentID" & vbCrLf & _
"WHERE tblAgents.RepType=" & cmbRepType & vbCrLf & _
"GROUP BY tblAgents.ID;"
End Function