Solved

how to export access table using VB6

Posted on 2002-07-19
4
288 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
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
PNJ earned 150 total points
Comment Utility
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
Comment Utility
Does the table in Data1.mdb already exist in Data2.mdb?
0
 
LVL 4

Expert Comment

by:gencross
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now