insert into syntax error

C

Co

Hi All,

I use following query to insert recs in a table:

sSQL = "INSERT INTO SID_Master_Archief IN " & sys.sDBMap &
"archief.mdb" & _
" SELECT ArchiefTmp.* FROM ArchiefTmp"

rsArchiefX.Execute (sSQL)

Now I get an error saying there is a syntax error in the sting.

MArco
 
D

Douglas J. Steele

What exactly does sSQL contain? Try using Debug.Print sSQL, then looking in
the Immediate Window (Ctrl-G) to see.
 
G

George Nicholson

it might just be a missing space before archief.mdb: " archief.mdb".

HTH,
 
C

Co

it might just be a missing space before archief.mdb: " archief.mdb".

HTH,

This is what I get from the Debug window:
INSERT INTO SID_Master_Archief IN 'D:\Archief.mdb' SELECT ArchiefTmp.*
FROM ArchiefTmp

Looks fine to me.

Marco
 
K

krissco

INSERT INTO SID_Master_Archief IN 'D:\Archief.mdb' SELECT ArchiefTmp.*
FROM ArchiefTmp

What type of object is rsArchiefX ?

Do the fields in SID_Master_Archief match up with the fields in
ArchiefTmp?

What happens when you run this query from the query builder (instead
of from code)?

Are you sure that is the correct syntax for modifying a table in
another database. I thought it was:

INSERT INTO [D:\Archief.mdb].SID_Master_Archief
SELECT *
FROM ArchiefTmp

but that might just be for the query builder.

-Kris
 
I

IUnderstandSomething

Hi All,

I use following query to insert recs in a table:

sSQL = "INSERT INTO SID_Master_Archief IN " & sys.sDBMap &
"archief.mdb" & _
" SELECT ArchiefTmp.* FROM ArchiefTmp"

rsArchiefX.Execute (sSQL)

Now I get an error saying there is a syntax error in the sting.

MArco

I made a quick check and my SQL became:
INSERT INTO Contacts ( FirstName, LastName ) IN 'D:\Documents and
Settings\Hans Kristian\My Documents\test.mdb'
SELECT MyContactTbl.FirstName, MyContactTbl.LastName
FROM MyContactTbl;

Sincerely
Hans Kristian Eide
 
Top