Solved

ADOX - Copy table to another Access db

Posted on 2001-08-06
8
562 Views
Last Modified: 2013-11-27
Hello all,

I have two Access 97 databases.  I need to copy certain tables from one to the other.

I'm using ADOX's catalog to find the table names.

My problem is that the source db is opened through a .mdw file with the user id and password, and when I try to do the copy I'm getting an error saying that that the db is opened by another user (ME!).

I tried using the table name from the catalog and doing a DoCmd.CopyObject and the TransferDatabase method, using the Access 8.0 Object Library, but I get the same error.

Does anyone have any ideas how to copy tables from a secured Access 97 db to an unsecure Access 97 db?

I will give 300 points and an A to anyone who can come up with the answer.

Thanks!

0
Comment
Question by:RichW
  • 6
8 Comments
 
LVL 3

Accepted Solution

by:
casassus earned 300 total points
ID: 6356323
Try to use a SQL clause like this one

I suppose that your ADO catalog name's is MyBase,your dest database name's is Dest.mdb, your dest table name's MyTableDest, your origine table name's MyTableOri

MyBase.execute "insert into MyTableDest in 'C:\...\Dest.mdb' select * from MyTableOri"



0
 
LVL 4

Author Comment

by:RichW
ID: 6356405
I tried this, but the catalog object doesn't have an Execute method.

0
 
LVL 4

Author Comment

by:RichW
ID: 6356419
I tried this, but the catalog object doesn't have an Execute method.

0
 
LVL 4

Author Comment

by:RichW
ID: 6356426
See the problem is I'm trying to copy the table object with the data.

I've used the code I have on two db's without security, and the tables copy perfectly.

The tables do not yet exist in the destination db.


0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 69

Expert Comment

by:Éric Moreau
ID: 6356434
<The tables do not yet exist in the destination db.>

instead of using INSERT INTO, use SELECT INTO (which will create the table).
0
 
LVL 4

Author Comment

by:RichW
ID: 6356497
Here's my code:

cat.ActiveConnection.Execute "Select into """ & strTblName & """  in  """ & strTarget & """"

The select statement comes out to:
Select into "CCPROCash"  in  "C:\Gateway\Gateway.mdb"

I get an error that says that there's a reserverd word or argument name that is misspelled.  This is not the case.  The table name is correct, and so is the path to the db.





0
 
LVL 4

Author Comment

by:RichW
ID: 6356524
Sorry.

Here's the select statement:
Select into CCPROCash  in  "C:\Gateway\Gateway.mdb" select * from CCPROCash

0
 
LVL 4

Author Comment

by:RichW
ID: 6356932
Thanks casassus.  I used the execute on the connection object and it worked.

emoreau thanks too.  

0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 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

20 Experts available now in Live!

Get 1:1 Help Now