SQL Syntax problem

  • Thread starter Thread starter AkAlan via AccessMonster.com
  • Start date Start date
A

AkAlan via AccessMonster.com

I am getting a syntax error "Line 1 incorrect syntax near ' = ' " when I
run the following:

strSQL = "APPEND tblEarByStatus SET RedHours = " & sngRedTime _
& ", Status = " & intCurEc _
& ", ParcTag = '" & strCurEquip & "'"

With cmd
.ActiveConnection = CurrentProject.Connection
.CommandText = strSQL
.CommandType = adCmdText
.Execute
End With

Here is what is in strSql :

"APPEND tblEarByStatus SET RedHours = 126.5, Status = 10, ParcTag = '00176'"

This looks like it should work but it doesn't. The variable types are as
follows :

sngRedTime is single
intCurEc is integer
strCurEquip is string.
Is it obvious what I'm doing wrong?

I'm new to project and SQl Server and I get my ass kicked by syntax errors
every time I try something different. Does anyone know where I can find a
good reference for how to correctly write SQL statements.
Thanks for any help.
 
There is no Append operator in SQL.

strSQL = "INSERT INTO tblEarByStatus " & _
"(RedHours, Status, ParcTag) " & _
"VALUES(" & sngRedTime & ", " & _
intCurEc & ", '" & strCurEquip & "'"
 
I might be wrong but I don't think that there is an APPEND command in
SQL-Server; you should use the Insert command instead:

Insert tblEarByStatus (RedHours, Status, ParcTag)
Values (126.5, 10, '00176')
 
Thanks Douglas, I wasn't even thinking I had the wrong command. I got it to
work after adding the closing parenthesis.
There is no Append operator in SQL.

strSQL = "INSERT INTO tblEarByStatus " & _
"(RedHours, Status, ParcTag) " & _
"VALUES(" & sngRedTime & ", " & _
intCurEc & ", '" & strCurEquip & "'"
I am getting a syntax error "Line 1 incorrect syntax near ' = ' " when I
run the following:
[quoted text clipped - 27 lines]
good reference for how to correctly write SQL statements.
Thanks for any help.
 
There is no APPEND command in SQL as implemented by MS SQL.
You probably want to user the INSERT command.
Look it up in Books On Line

Cheers,
 
Back
Top