• Help With SQL Syntax? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Help With SQL Syntax? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Author
    Topic
    #450647

    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

    Viewing 0 reply threads
    Author
    Replies
    • #1107664

      I retyped it and it works

      strSQL = "SELECT Count(curVBen) AS NumberOfRecords, " & _
                      "Sum(curVFee) AS TotalFee, " & _
                      "Sum(curAmtAllowed) AS TotalAllowed " _
                      & "FROM " & strTable & " " _
                      & "WHERE (((" & strTable & "." & strCode & ") " _
                      & "= '" & gloGetValue("StartProcedureGroupCode") & "' " _
                      & "AND ((" & strTable & ".idsKeyOfPersonal)=" _
                      & PersonalID & ")))"
      
    Viewing 0 reply threads
    Reply To: Help With SQL Syntax? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: