SQL Syntax problem

  • Thread starter AkAlan via AccessMonster.com
  • 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.
 
D

Douglas J. Steele

There is no Append operator in SQL.

strSQL = "INSERT INTO tblEarByStatus " & _
"(RedHours, Status, ParcTag) " & _
"VALUES(" & sngRedTime & ", " & _
intCurEc & ", '" & strCurEquip & "'"
 
S

Sylvain Lafontaine

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')
 
A

AkAlan via AccessMonster.com

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.
 
M

Malcolm Cook

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top