I am using Access 2003. With extensive help yesterday I have a string that works to run a query. I want to use this query to run multiple times with different information. So I added variables to the string and now i am getting an error 3141 . I am pretty sure I have the quotes messed up somewhere I JUST DON'T KNOW WHERE.
Tom
This code works
This Code doesn't work the error is on the red line
Tom
This code works
Code:
strSQL = "TRANSFORM Sum(proc) AS SumOfproc " & _
"SELECT uci, readingprovname as [rp] " & _
"FROM PROC_ReadingProvider " & _
"WHERE billpd>357 " & _
"GROUP BY uci, readingprovname " & _
"PIVOT billpd"
This Code doesn't work the error is on the red line
Code:
strFld1 = "proc"
strSel1 = "uci"
strSel2 = "readingprovname "
strTbl = "PROC_ReadingProvider "
strWhr = "billpd"
iWhr = 357
strSQL = "TRANSFORM Sum(" & strFld1 & ")" & "AS SumOf" & strFld1 & "" & _
"SELECT " & strSel1 & "," & strSel2 & "" & _
"FROM " & strTbl & "" & _
"WHERE " & strWhr & ">" & iWhr & "" & _
"GROUP BY " & strSel1 & "," & strSel2 & "" & _
"PIVOT " & strWhr & ""
[red]Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)[/red]