What is the proper syntax for an (INSERT) append query ?

G

Gordon

Hi ;

I keep getting a "Syntax error in Insert" message when I try to execute the
following.

dim holdFlNme = "c:\myWorkbook.xls"
"INSERT INTO [_unit_difference] '" & holdFlNme & "' Excel 8.0; Select * from
[unit_difference]"

Can anyone see the syntax problem ?

Thanks,
 
M

Michel Walsh

Hi,


INSERT INTO functionality is to insert records into a table, not into a
file. LINK the file to see it "as a table" and, if it is updateable (not all
ISAM drivers allow update) use the standard syntax to insert into a table.
Else, try a DoCmd.TransferXYZ, not SQL.



Hoping it may help,
Vanderghast, Access MVP
 
G

Gordon

Hi;

I found out what the problem was.

It was the holdFlName parameter in the insert statement.

{My original INSERT which was }

"INSERT INTO [_unit_difference] '" & holdFlNme & "' Excel 8.0; Select * from
[unit_difference]"


{Working Statement }

"INSERT INTO [_unit_difference] " & holdFlNme & " Excel 8.0; Select * from
[unit_difference]"

To read the contents of holdFLName use " & holdFlName & " enclose in double
quotes only .

I confused the parameter here with the syntax used in a SELECT statement i.e.
anSQL = "Select Somename from MyTable WHERE SomeName = '" & holdNAme & "'
".
Where the value to compare is enclosed by a single and double quote

Thanks
--
Gordon


Michel Walsh said:
Hi,


INSERT INTO functionality is to insert records into a table, not into a
file. LINK the file to see it "as a table" and, if it is updateable (not all
ISAM drivers allow update) use the standard syntax to insert into a table.
Else, try a DoCmd.TransferXYZ, not SQL.



Hoping it may help,
Vanderghast, Access MVP


Gordon said:
Hi ;

I keep getting a "Syntax error in Insert" message when I try to execute
the
following.

dim holdFlNme = "c:\myWorkbook.xls"
"INSERT INTO [_unit_difference] '" & holdFlNme & "' Excel 8.0; Select *
from
[unit_difference]"

Can anyone see the syntax problem ?

Thanks,
 

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