The following works OK
strSQL = "SELECT Count(curVBen) AS NumberOfRecords, " & _ "Sum(curVBen) AS TotalBenefit, " & _ "Sum(curVFee) AS TotalFee, " & _ "Sum(curAmtAllowed) AS TotalAllowed, " & _ "Sum(curAmtApplToDed) AS ApplToDed, " & _ "Sum(curAmtNotCovered) AS NotCovered " _ & "FROM " & strTable & " " _ & "WHERE (((" & strTable & ".dteVDATE) " _ & "BETWEEN #" & gloGetValue("StartDate") & "# " _ & "AND #" & gloGetValue("EndDate") & "#) " _ & "AND ((" & strTable & "." & strCode & ") " _ & "BETWEEN '" & gloGetValue("StartProcedureGroupCode") & "' " _ & "AND '" & gloGetValue("EndProcedureGroupCode") & "') " _ & "AND ((" & strTable & ".idsKeyOfPersonal)=" _ & PersonalID & "))"
I’m trying to streamline the following code in a form and I’m getting and I am getting “3265 Item not found in collection” error
strSQL = "SELECT Count(curVBen) AS NumberOfRecords, " & _ "Sum(curVBen) AS TotalBenefit, " & _ "Sum(curAmtAllowed) AS TotalAllowed " _ & "FROM " & strTable & " " _ & "WHERE (((" & strTable & "." & strCode & ") " _ & "= '" & gloGetValue("StartProcedureGroupCode") & "' " _ & "AND ((" & strTable & ".idsKeyOfPersonal)=" _ & PersonalID & ")))" Debug.Print strSQL
However, I can run the the contents of strSQL in query grid OK
SELECT Count(curVBen) AS NumberOfRecords, Sum(curVBen) AS TotalBenefit, Sum(curAmtAllowed) AS TotalAllowed FROM qrytblSumServetblVouch2_NoVoids WHERE (((qrytblSumServetblVouch2_NoVoids.strProcedureGroup) = 'O' AND ((qrytblSumServetblVouch2_NoVoids.idsKeyOfPersonal)=1632)))
Where is my problem?
Thanks, John