Question : Whats wrong with the syntax - sql string

Need another pair of eyes I just don't see the problem with the attached sql string.

Karen
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
strSQL = "INSERT INTO audit ( APNO, WSNo, EditDate, [User], SourceField )" & _
            " SELECT Getgapno() AS APNO, A.WS_No, A.DtAppnWS, Environ('username') AS User1, "WS Add" AS SourceField" & _
                " FROM Audit RIGHT JOIN" & _
                " (SELECT TA_WS.WS_No, TA_WS.WS_ActCd, TA_WS.WS_Title, TA_WS.WS_CntrlCd," & _
                    " TA_WS.WS_DtTgtEngr, TA_WS.WS_DwgNo, TA_WS.DtAppnWS" & _
                    " FROM TA_WS" & _
                    " GROUP BY TA_WS.WS_No, TA_WS.WS_ActCd, TA_WS.WS_Title, TA_WS.WS_CntrlCd, TA_WS.WS_DtTgtEngr, TA_WS.WS_DwgNo," & _
                    " TA_WS.DtAppnWS" & _
            " HAVING (((TA_WS.WS_No)<>Exists" & _
                " (SELECT WSNo FROM Audit WHERE (((APNO)=getgapno()) AND" & _
                " ((EditDate) Between GetgISISDate() And Date()) AND ((SourceField)='WS Add')))) AND" & _
                " ((TA_WS.DtAppnWS)>=GetgISISDate()))) AS A" & _
                " ON Audit.WSNo = A.WS_No" & _
                " WHERE (((Audit.WSNo) Is Null))"

Answer : Whats wrong with the syntax - sql string

There may well be other errors too, but this:

           " SELECT Getgapno() AS APNO, A.WS_No, A.DtAppnWS, Environ('username') AS User1, "WS Add" AS SourceField" & _

should be:

           " SELECT Getgapno() AS APNO, A.WS_No, A.DtAppnWS, Environ('username') AS User1, 'WS Add' AS SourceField" & _

or:

           " SELECT Getgapno() AS APNO, A.WS_No, A.DtAppnWS, Environ('username') AS User1, ""WS Add"" AS SourceField" & _

Random Solutions  
 
programming4us programming4us