Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

runtime error 3075 syntax error (missing operator) 1

Status
Not open for further replies.

vba317

Programmer
Mar 5, 2009
708
0
0
US
I am getting an error 3075 when ever my routine gets to this point in the program.
The whole error is Syntax error (missing operator) in query expression '(grpdsc1='CARITAS ST. ELIZABETH'S MED CTR') GROUP BY fydiff,rptpd,fymonord ORDER BY rptpd
I originally thought nulls could have caused this error. I checked the table PROC_RptSrc_ExecSumm and it has zeros in it but no nulls.
The error point is highlighted in blue
Any help is appreciated
Tom


Code:
The original procedure 

 strSQL = "SELECT fydiff,rptpd,fymonord as fyord,Sum(proctot) AS prcs,Sum(chg) AS chgs,Sum(ca) AS cadj,Sum(wo) AS woff" & _
                    ",Sum(pmt) AS pmts,Sum(dr) AS deb,Sum(ar) AS arec,Sum(arover90) AS ar90,Sum(last3chg) AS lst3 " & _
            "FROM PROC_RptSrc_ExecSumm " & _
            "GROUP BY fydiff,rptpd,fymonord " & _
            "ORDER BY rptpd;"
Call ExecSumm_Grp_DataScript(iRw, strSQL)

Public Sub ExecSumm_Grp_DataScript(iBaseRw As Integer, strESSQL As String)

'*** THIS SUB ADDS THE SUB DATA TO A EXECUTIVE SUMMARY SECTION
Dim rstES As Recordset
Dim iESRec As Integer

' Add Data
[Blue] Set rstES = CurrentDb.OpenRecordset(strESSQL, dbOpenSnapshot) [/Blue]
If Not rstES.EOF Then
    With rstES
        .MoveLast
        .MoveFirst
    End With
    For iESRec = 1 To rstES.RecordCount
        If (rstES![fydiff] = 0) Then ' Current Year
            With goXL.ActiveSheet
                .Cells((rstES![fyord] + iBaseRw + 4), 3).Value = (rstES![prcs])
                .Cells((rstES![fyord] + iBaseRw + 4), 4).Value = (rstES![chgs])
                .Cells((rstES![fyord] + iBaseRw + 4), 6).Value = (rstES![cadj])
                .Cells((rstES![fyord] + iBaseRw + 4), 7).Value = (rstES![woff])
                .Cells((rstES![fyord] + iBaseRw + 4), 9).Value = (rstES![pmts])
                .Cells((rstES![fyord] + iBaseRw + 4), 10).Value = (rstES![deb])
                .Cells((rstES![fyord] + iBaseRw + 4), 15).Value = (rstES![arec])
                .Cells((rstES![fyord] + iBaseRw + 4), 17).Value = (rstES![ar90])
                .Cells((rstES![fyord] + iBaseRw + 4), 23).Value = (rstES![lst3])
            End With
        Else ' Prior Year
            With goXL.ActiveSheet
                .Cells((rstES![fyord] + iBaseRw + 4), 43).Value = (rstES![prcs])
                .Cells((rstES![fyord] + iBaseRw + 4), 44).Value = (rstES![chgs])
                .Cells((rstES![fyord] + iBaseRw + 4), 45).Value = (rstES![cadj])
                .Cells((rstES![fyord] + iBaseRw + 4), 46).Value = (rstES![woff])
                .Cells((rstES![fyord] + iBaseRw + 4), 47).Value = (rstES![pmts])
                .Cells((rstES![fyord] + iBaseRw + 4), 48).Value = (rstES![deb])
                .Cells((rstES![fyord] + iBaseRw + 4), 40).Value = (rstES![arec])
                .Cells((rstES![fyord] + iBaseRw + 4), 42).Value = (rstES![ar90])
                .Cells((rstES![fyord] + iBaseRw + 4), 39).Value = (rstES![lst3])
            End With
        End If
        rstES.MoveNext
    Next iESRec
End If
' Close Data
rstES.Close
Set rstES = Nothing

End Sub
 
I don't see how [highlight #FCE94F](grpdsc1='CARITAS ST. ELIZABETH'S MED CTR')[/highlight] gets into the strSQL. However, there is an apostrophe in the name that is causing the issue. You should replace the apostrophe with two apostrophes.

Duane
Hook'D on Access
MS Access MVP
 
Duane,
I forgot to include the code that included the grpdsc1 in it. I found the table that the 'CARITAS ST. ELIZABETH'S MED CTR was located and removed the apostrophe and now everything works great!
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top