-1

I am currently using the routine proposed by Vivek to export the data of an Access 2013 table (tables linked by dsn odbc) to a csv file Everything works fine

But how to do the reverse operation, therefore having the table empty and wanting to import (via vba code then automatically) the same data exported before, how to proceed?

amorosik
  • 1
  • 1
  • Do you want to do it via code for automation, or do it manually? Solution to do manually: https://blog.ip2location.com/knowledge-base/how-to-import-csv-into-microsoft-access-database/ – Lies Dec 19 '21 at 15:37
  • Not manually, automatically via vba code What I would like to create are two generic functions that were able to export and import data from any table in the database, regardless of the structure of the tables Obviously the data import will be performed exclusively from the csv files that have been written with the data export function from that table – amorosik Dec 19 '21 at 15:59
  • Better add that info to the question for clarification – Lies Dec 19 '21 at 16:56
  • Does this answer your question? [VBA procedure to import csv file into access](https://stackoverflow.com/questions/11275356/vba-procedure-to-import-csv-file-into-access) – Lies Dec 19 '21 at 16:59
  • A quick search with the keywords give me multiple results. Next time try to search first before posting a question keywords import csv into access database vba – Lies Dec 19 '21 at 17:00
  • "... give me multiple results...." NO For exporting and importing data on Microsoft Access table the DoCmd.Transfertext command is mainly used But, TransferText require a table structure The example of Vivek is based on a different approch His example not require table structure, but is function correctly Then my question is, how to 'invert' the example to import data – amorosik Dec 19 '21 at 17:11
  • Does this answer your question? [Read/Parse text file line by line in VBA](https://stackoverflow.com/questions/11528694/read-parse-text-file-line-by-line-in-vba) – June7 Dec 19 '21 at 19:08

1 Answers1

0

But why use this severely limited file format? Export to an Access database, and you keep everything from the original table:

DbEngine(0).CreateDatabase "C:\Test\Backup.accdb", dbLangGeneral, dbVersion120
DoCmd.CopyObject "C:\Test\Backup.accdb", "Products", acTable, "Products"

If you wish to copy all tables in the database, use this simple call:

SaveAsText 6, "", "C:\Test\Tables.accdb"
Gustav
  • 53,498
  • 7
  • 29
  • 55