Import text file to access database via Excel VBA

D

Dan

Is it possible to import a text file into an access database via Excel.
The Access Table that the file should be imported already exist - it just
should be emptied of data and populated by the new data from the text file.
Thank you
Dan
 
J

joel

You neede a macro to write to an Access Database from Excel. You can import
data directly in Access from a file witout using Excel. You can query a
Database from excel without a macro.

there are different methods that can read/write to access using a macro
depending the version of access that was used to create the database. The
two main ways of access the database is using the ADO or DAO methods.

I usually refer to the Access VBA help menu along with a book I bought.
when access the database from excel I create an Access Application and then
use ACCESS methods to read and write the data. You also need to add refernce
libraries to the excel vba (tools - references)

Add the following references
Microsoft Access 11.0 object library (or latest version)
Microsoft ActiveX data ojects 2.8 library (for ADO method, use latestt
library)

Creating and Access object in excel vba

Set obj = createobject("Access.Application")

or open an existing database

set db = GetObject("c:\temp\dbase1.mdb")
 

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