|
Question : Missing ; at end of SQL statement
|
|
Hi, I have tried this several times, having the same error message. Please help. I get the error message that I am missing the ; at the end of the SQL statement. If I put one, I get a message saying the ; should not be there.
I originally copied the code from an append query, but I wish to have it in code, rather than queries. TIA Susan
Dim db As DAO.Database Set db = CurrentDb() Dim sql As String
sql = "INSERT INTO [Personal Injuries 2009] ( [DATE], NAME, [POSITION TYPE], LOCATION, " & _ "[LOCATION MANAGER], [ZONE Or REGION], [ALIUS INJURY CLASSIFICATION], [CONTRACTOR INJURY CLASSIFICATION], " & _ "[REPORTED DATE], [DAYS TO REPORT], [RCA COMPLETION DATE], [DAYS TO INVESTIGATE], " & _ "[HSE Exception #], [CONTRIBUTING STATE OF MIND], [CONTRIBUTING CRITICAL ERROR], " & _ "[INCIDENT DESCRIPTION], ACTIVITY, [INJURY TYPE], DESCRIPTION, Notations, Comment1, Comment2, Comment3 )" & _ "Values(INJ2009ImportL1.DATE, INJ2009ImportL1.NAME, INJ2009ImportL1.[POSITION TYPE], " & _ "INJ2009ImportL1.LOCATION, INJ2009ImportL1.[LOCATION MANAGER], INJ2009ImportL1.[ZONE OR REGION]," & _ "INJ2009ImportL1.[ALIUS INJURY CLASSIFICATION], INJ2009ImportL1.[CONTRACTOR INJURY CLASSIFICATION]," & _ "INJ2009ImportL1.[REPORTED DATE], INJ2009ImportL1.[DAYS TO REPORT], INJ2009ImportL1.[RCA COMPLETION DATE], " & _ "INJ2009ImportL1.[DAYS TO INVESTIGATE], INJ2009ImportL1.[HSE Exception #], INJ2009ImportL1.[CONTRIBUTING STATE OF MIND]," & _ "INJ2009ImportL1.[CONTRIBUTING CRITICAL ERROR], INJ2009ImportL1.[INCIDENT DESCRIPTION], INJ2009ImportL1.ACTIVITY, " & _ "INJ2009ImportL1.[INJURY TYPE], INJ2009ImportL1.DESCRIPTION, INJ2009ImportL1.Notations, INJ2009ImportL1.Comment1," & _ "INJ2009ImportL1.Comment2, INJ2009ImportL1.Comment3) " & _ "WHERE (((INJ2009ImportL1.DATE) Is Not Null)) OR (((INJ2009ImportL1.NAME) Is Not Null));"
|
|
Answer : Missing ; at end of SQL statement
|
|
I'm afraid you have the wrong type of query. You need:
sql = "INSERT INTO [Personal Injuries 2009] ( [DATE], NAME, [POSITION TYPE], LOCATION, " & _ "[LOCATION MANAGER], [ZONE Or REGION], [ALIUS INJURY CLASSIFICATION], [CONTRACTOR INJURY CLASSIFICATION], " & _ "[REPORTED DATE], [DAYS TO REPORT], [RCA COMPLETION DATE], [DAYS TO INVESTIGATE], " & _ "[HSE Exception #], [CONTRIBUTING STATE OF MIND], [CONTRIBUTING CRITICAL ERROR], " & _ "[INCIDENT DESCRIPTION], ACTIVITY, [INJURY TYPE], DESCRIPTION, Notations, Comment1, Comment2, Comment3 ) " & _ "SELECT INJ2009ImportL1.DATE, INJ2009ImportL1.NAME, INJ2009ImportL1.[POSITION TYPE], " & _ "INJ2009ImportL1.LOCATION, INJ2009ImportL1.[LOCATION MANAGER], INJ2009ImportL1.[ZONE OR REGION], " & _ "INJ2009ImportL1.[ALIUS INJURY CLASSIFICATION], INJ2009ImportL1.[CONTRACTOR INJURY CLASSIFICATION], " & _ "INJ2009ImportL1.[REPORTED DATE], INJ2009ImportL1.[DAYS TO REPORT], INJ2009ImportL1.[RCA COMPLETION DATE], " & _ "INJ2009ImportL1.[DAYS TO INVESTIGATE], INJ2009ImportL1.[HSE Exception #], INJ2009ImportL1.[CONTRIBUTING STATE OF MIND], " & _ "INJ2009ImportL1.[CONTRIBUTING CRITICAL ERROR], INJ2009ImportL1.[INCIDENT DESCRIPTION], INJ2009ImportL1.ACTIVITY, " & _ "INJ2009ImportL1.[INJURY TYPE], INJ2009ImportL1.DESCRIPTION, INJ2009ImportL1.Notations, INJ2009ImportL1.Comment1, " & _ "INJ2009ImportL1.Comment2, INJ2009ImportL1.Comment3) " & _ "FROM INJ2009ImportL1 WHERE (((INJ2009ImportL1.[DATE]) Is Not Null)) OR (((INJ2009ImportL1.NAME) Is Not Null));"
|
|
|
|