?
Solved

how to export access table using VB6

Posted on 2002-07-19
4
Medium Priority
?
296 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 600 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

752 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