• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • Last Modified:

how to export access table using VB6


By using VB6 code, how can I :
1)Export  Table1 from Data1.mdb to Data2.mdb
2)Copy Data1.mdb to Data2.mdb (Overwrite on Data2.mdb or save Data1.mdb as Data2.mdb) – without any warning messages

What is the VB6 code which does each item?
Note: I use Access 2000

I look forward your code. Your efforts and help are completely appreciated.

Thanx in advance
  • 2
1 Solution
1) can be as simple as:

   FileCopy Data1.mdb, Data2.mdb

(FileCopy just copies any old file to another)

2) If you scan the Help files of VB6 for "DELETE", "SELECT" and "INSERT INTO" the examples given will start you off. I was thinking along the lines of "DELETE" everything from Data2.mdb and the using "SELECT" to get the correct records from Data1 (into a recordset) and "INSERT INTO" to write them into, the now empty, Data2.

I don't use Access programatically, so don't have any useful code snippets.
Does the table in Data1.mdb already exist in Data2.mdb?
This is not as easy as one might think.  Here is a link to code that will compare two databases and sync them (I believe).  I'm sure it has what you need and you can strip out the code you don't need.


To expound on PHJ's copy routine...

You first delete the Data2.mdb then copy the Data1.mdb to Data2.mdb

Kill "c:\Data2.mdb"
FileCopy "c:\Data1.mdb","c:\Data2.mdb"
This example uses dao and inserts a table from one db to another

mydb.Execute "SELECT * Into Table1 FROM Table1 IN '' [MS Access;DATABASE=" & MyDbPath & ";TABLE=Table1;pwd=mypwd];"

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now