need help, getting syntax error in INSERT INTO statement

DK8

Registered User.
Local time
Today, 11:34
Joined
Apr 19, 2007
Messages
72
I modified a module, which was initally working fine when we tested it, but now I'm getting a syntax error in INSERT INTO statement (3134) DAO.Database. I have looked over the table and stored procedure, which all look fine. The syntax error must be in the code, but I'm not seeing it. Can someone take a look at this code and tell me what's causing this error? Thanks in advance, here is the code:

'
' Retrieve Group Number Updates
'
With rstGroupRecs
.CursorLocation = adUseClient
.CursorType = adOpenForwardOnly
.LockType = adLockReadOnly
.ActiveConnection = g_conOLEDB
.Open "Exec spSelectGroupNumberUpdates"

If (Not (rstGroupRecs.EOF)) Then

dbsBillSysDB.Execute "DELETE * FROM [GROUP NUMBER UPDATE TABLE];", dbSeeChanges

Do While (Not (rstGroupRecs.EOF))

strSQL = "INSERT INTO [GROUP NUMBER UPDATE TABLE] ( [DEDUCTION GROUP NUMBER], [EMPLOYEE GROUP NUMBER], " & _
"[EMPLOYEE SSN], [SERVICE CODE], [EMPLOYER NUMBER], " & _
"[OLD EMPLOYER NUMBER])" 'added by DEK 6/15/07
strSQL = strSQL & " SELECT '" & rstGroupRecs.Fields("DEDUCTION GROUP NUMBER").Value & "', "
strSQL = strSQL & "'" & rstGroupRecs.Fields("EMPLOYEE GROUP NUMBER").Value & "' , "
strSQL = strSQL & "'" & rstGroupRecs.Fields("EMPLOYEE SSN").Value & "' , "
strSQL = strSQL & "'" & rstGroupRecs.Fields("SERVICE CODE").Value & "', "
strSQL = strSQL & " " & rstGroupRecs.Fields("NEWCLIENTNO").Value & " , " 'added by DEK 6/15/07
strSQL = strSQL & " " & rstGroupRecs.Fields("OLDCLIENTNO").Value & " " 'added by DEK 6/15/07

dbsBillSysDB.Execute strSQL, dbSeeChanges

rstGroupRecs.MoveNext

Loop

If (Are_There_Records("GROUP NUMBER UPDATE TABLE")) Then
DoCmd.OpenReport "GROUP NUMBER FILE LOAD UPDATES REPORT", acViewNormal
End If
End If

.Close
End With
 
could it be a missing semicolon at the end of strSQL =
?
 
You're fetching the results of an SP from SQL server in a ADO recordset, then per each row in that recordset, you're adding a record to a local (Jet?) table through using DAO execute?

Yes, the error probably occurs on the dbsBillSysDB.Execute strSQL, dbSeeChanges line, so if if you could do a

debug.print strSQL

when it errors, it might help. Also, indicating what datatype the different fields have, might make it easier to assist.

Ordinary, I'd probably write an insert statement more like this

INSERT INTO myTable (textfield, datefield, numberfield)
VALUES ('Arthur Dent', #2007-10-12#, 42)
 

Users who are viewing this thread

Back
Top Bottom