Append to table in VBA

  • Thread starter Thread starter dimpie
  • Start date Start date
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
 
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
 
Back
Top