Solved

how to export access table using VB6

Posted on 2002-07-19
4
294 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

732 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