Help on syntax error (comma) in Query Expression

V

Vandy

Hi,

I am getting the above error while trying to insert the records.

strtstNIV = "2"

StrSQL = "Insert into olyfweb_fdbdoc (tstNIV,tstRAC)" & _
"Select (""" & strtstNIV & """,qrytabtest.[JURACI])" & _
"FROM qrytabtest;"

CurrentDb.Execute StrSQL, dbFailOnError


If I have only one column tstRAC and run with query, it is updating
successfully for all records ( Note that all other columns updated with
spaces).

If I am run with 2 columns as mentioned above, it is ending with errror
message.

Any advice on this?

Thanks
 
J

John Spencer

Your posted code is missing a space before the word SELECT and before the
word FROM.

Is the field tstNIV a number field or a text field. If it is a number field
then drop the quotes. If it is a text value then keep the quote marks
Also drop the Parentheses in the SELECT statement

Assumption:
tstInv is a number field.

StrSQL = "Insert into olyfweb_fdbdoc (tstNIV,tstRAC)" & _
" SELECT " & strtstNIV & ", qrytabtest.[JURACI]" & _
" FROM qrytabtest;"
 
M

Marshall Barton

Vandy said:
I am getting the above error while trying to insert the records.

strtstNIV = "2"

StrSQL = "Insert into olyfweb_fdbdoc (tstNIV,tstRAC)" & _
"Select (""" & strtstNIV & """,qrytabtest.[JURACI])" & _
"FROM qrytabtest;"

CurrentDb.Execute StrSQL, dbFailOnError


If I have only one column tstRAC and run with query, it is updating
successfully for all records ( Note that all other columns updated with
spaces).

If I am run with 2 columns as mentioned above, it is ending with errror
message.


Get rid or the ( and ) in the SELECT part of the query.

It also appears that you are missing a space near the end of
each line:

StrSQL = "Insert into olyfweb_fdbdoc (tstNIV, tstRAC) " & _
"Select """ & strtstNIV & """, qrytabtest.JURACI " & _
"FROM qrytabtest;"

Are you sure that the field tstNIV is a Text field?
 
V

Vandy

Marshall said:
Vandy said:
I am getting the above error while trying to insert the records.

strtstNIV = "2"

StrSQL = "Insert into olyfweb_fdbdoc (tstNIV,tstRAC)" & _
"Select (""" & strtstNIV & """,qrytabtest.[JURACI])" & _
"FROM qrytabtest;"

CurrentDb.Execute StrSQL, dbFailOnError


If I have only one column tstRAC and run with query, it is updating
successfully for all records ( Note that all other columns updated with
spaces).

If I am run with 2 columns as mentioned above, it is ending with errror
message.


Get rid or the ( and ) in the SELECT part of the query.

It also appears that you are missing a space near the end of
each line:

StrSQL = "Insert into olyfweb_fdbdoc (tstNIV, tstRAC) " & _
"Select """ & strtstNIV & """, qrytabtest.JURACI " & _
"FROM qrytabtest;"

Are you sure that the field tstNIV is a Text field?

Thank You all,

I removed the "(" next to Select Statement and it went through.

Thanks a lot.
 
V

Vandy

Marshall said:
Vandy said:
I am getting the above error while trying to insert the records.

strtstNIV = "2"

StrSQL = "Insert into olyfweb_fdbdoc (tstNIV,tstRAC)" & _
"Select (""" & strtstNIV & """,qrytabtest.[JURACI])" & _
"FROM qrytabtest;"

CurrentDb.Execute StrSQL, dbFailOnError


If I have only one column tstRAC and run with query, it is updating
successfully for all records ( Note that all other columns updated with
spaces).

If I am run with 2 columns as mentioned above, it is ending with errror
message.


Get rid or the ( and ) in the SELECT part of the query.

It also appears that you are missing a space near the end of
each line:

StrSQL = "Insert into olyfweb_fdbdoc (tstNIV, tstRAC) " & _
"Select """ & strtstNIV & """, qrytabtest.JURACI " & _
"FROM qrytabtest;"

Are you sure that the field tstNIV is a Text field?

Thank You all,

I removed the "(" next to Select Statement and it went through.

Thanks a lot.
 

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