SQL Syntax Error

N

njl

I have some VB code behind a form which generates a simple SQL
statement but it does not execute - I get "Syntax Error in Insert
Into" error message.

VB Code is :

strSQL = "DELETE * FROM tblYear"

cnnCLUB.BeginTrans
cnnCLUB.Execute (strSQL)

strSQL = "INSERT INTO tblYear ( ID, StartofYear, Open, Closed ) "
& _
"VALUES( " & txtYear & ", '01/01/" & txtYear & "', Yes, No)"

cnnCLUB.Execute (strSQL)
cnnCLUB.CommitTrans

cnnCLUB is an open ADO Connection to an Access database

The first SQL command (DELETE ... ) executes ok but the INSERT does
not. The contents of strSQL when the INSERT command is executed are :

INSERT INTO tblYear ( ID, StartofYear, Open, Closed ) VALUES( 2003,
'01/01/2003', Yes, No)


If I go into the immediate window & print strSQL, create a new query
with this code & execute it works ok, implying syntax is fine.

Any ideas ??
 

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