After alot of help I have converted a crosstab query in vba that works. It is as follows:
After reviewing the data I have realized I need to factor out if a field is greater than 0 I don't want any results. I have been working all kinds of different combinations, all day, in the where clause with no luck. Now I am trying the having clause and I am getting the error 3141. Is it possible to write a crosstab query with two sums? I have been using the debug.print statement to verify the issue is not spaces. Any help in this matter would be appreciated.
Debug.print results
TRANSFORM Sum(proc)AS SumOfproc SELECT uci,readingprovname FROM PROC_ReadingProvider WHERE billpd>369 GROUP BY uci,readingprovname HAVING SUM proc>0 PIVOT billpd
Current code
Code:
strSql = "TRANSFORM Sum(" & strFld1 & ")" & "AS SumOf" & strFld1 & _
' " SELECT " & strSel1 & "," & strSel2 & _
' " FROM " & strTbl & _
' " WHERE " & strWhr & ">" & [iWhr] & _
' " GROUP BY " & strSel1 & "," & strSel2 & _
' " PIVOT " & strWhr & ""
After reviewing the data I have realized I need to factor out if a field is greater than 0 I don't want any results. I have been working all kinds of different combinations, all day, in the where clause with no luck. Now I am trying the having clause and I am getting the error 3141. Is it possible to write a crosstab query with two sums? I have been using the debug.print statement to verify the issue is not spaces. Any help in this matter would be appreciated.
Debug.print results
TRANSFORM Sum(proc)AS SumOfproc SELECT uci,readingprovname FROM PROC_ReadingProvider WHERE billpd>369 GROUP BY uci,readingprovname HAVING SUM proc>0 PIVOT billpd
Current code
Code:
strSql = "TRANSFORM Sum(" & strFld1 & ")" & "AS SumOf" & strFld1 & _
" SELECT " & strSel1 & "," & strSel2 & _
" FROM " & strTbl & _
" WHERE " & strWhr & ">" & [iWhr] & _
" GROUP BY " & strSel1 & "," & strSel2 & _
" HAVING SUM " & strFld1 & ">" & 0 & _
" PIVOT " & strWhr & ""