Append to table in VBA

D

dimpie

I am trying to append records into a table that has just one field. I am
trying to do this in VBA into access table.

Table name - tbl_FileName
Variable that has data to be inserted - Ins_FileName

CODE that i am using(but not wroking:

Ins_Filename = Right(str_filename, 28)

SQL = "INSERT INTO tbl_FileName ( FileName ) " & _
"SELECT [Ins_Filename]"

DoCmd.RunSQL SQL


When I run this it is looking Ins_FileName as a parameter value. But
Ins_Filename already is stored with a data.

Anyhelp is appreciated. Thank you
 
P

Paolo

Hi dimpie,
write the SQL statement in this way and it'll surely work

SQL = "INSERT INTO tbl_FileName ( FileName ) " & _
"SELECT " & Ins_Filename

to avoid the DoCmd.RunSQL SQL statement you can do as follow

currentdb.execute ("INSERT INTO tbl_FileName ( FileName ) " & _
"SELECT " & Ins_Filename)

HTH Paolo
 

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