VBA Code for 'Append Data To Existing Table' option

SSANKA2

New member
Local time
Today, 13:44
Joined
Jul 15, 2015
Messages
2
Hi All,

I am trying to write a VBA Code that does the same job as 'Append Data To Existing Table' option, while copy-pasting a Table within the same DB. I have tried my luck with:

DoCmd.TransferDatabase acExport, "Microsoft Access", CurrentDb.Name, acTable, "Tbl_ApplCnt", "Tbl_ApplCnt_Unique", StructureOnly:=True

CurrentDb.Execute "CREATE UNIQUE INDEX assetnum ON Tbl_ApplCnt_Unique (assetnum) WITH PRIMARY"

DoCmd.TransferDatabase acExport, "Microsoft Access", CurrentDb.Name, acTable, "Tbl_ApplCnt", "Tbl_ApplCnt_Unique", StructureOnly:=False

However, when I try: StructureOnly:=False I end up pasting the entire table again & my effort to create a primary key (& hence a result table with Unique 'assetnum') fails.

I need something like: AppendDataToExistingTable:=True

I have tried Google one entire day, yet came up with nothing. :banghead:
I promise to include the 'helper' in my prayers every day. Pls help.
 

Attachments

  • Image.png
    Image.png
    22.8 KB · Views: 185
Last edited:
It sounds like all you need is an append query which you execute with vba - something like

currentdb.execute("INSERT INTO DestinationTable SELECT * FROM SourceTable")

if both tables have the same structure
 
CJ_London: Works like a charm... :)

Thanks a TON...!!
 

Users who are viewing this thread

Back
Top Bottom