Solved

how to export access table using VB6

Posted on 2002-07-19
4
293 Views
Last Modified: 2011-04-14
Hi,

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
asns
0
Comment
Question by:asns
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
PNJ earned 150 total points
ID: 7164537
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.
0
 
LVL 4

Expert Comment

by:gencross
ID: 7164605
Does the table in Data1.mdb already exist in Data2.mdb?
0
 
LVL 4

Expert Comment

by:gencross
ID: 7164680
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.

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=35186&lngWId=1

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"
0
 

Expert Comment

by:haggmar
ID: 7164914
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];"
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Cannot Load VB6 on Windows 10. Installed OK but error on opening existing project. 7 115
Hide vba in gp 7 113
MsgBox 4 71
adding "ungroup sheets" to existing vbs code 5 52
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question