473,388 Members | 1,391 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Link external Databases

Sam
Hey,

Basically the code below, should first create a database and then copy
the tables from one external database to this newly created database.
At the moment I am using a third access database file to perform this
task, (I would code it in VB, but we don't currently own a version).
This code works a treat if you copy the CurrentDB where the code is
running to a new database, but I need the code to access another
database, the code I have used is below. As you can see I have
replaced the CurrentDB with the necessary path name. The error I get
though is...

The Microsoft Jet database engine could not find the object
'TableNameInHere'. Make sure the object exists and that you spell its
name and the path name correctly.

I understand the problem but as it works using CurrentDB i'm stuck Any
help is greatly appreciated,

Cheers

Sam

Code Is here

Sub sExport(strDBName As String)
On Error GoTo E_Handle
Dim db As DAO.Database
Dim tdf As DAO.TableDef
If Dir(strDBName) <> "" Then Kill strDBName
Set db = DBEngine(0).CreateDatabase(strDBName, dbLangGeneral)
db.Close
Set db = DBEngine.OpenDatabase("C:\Documents and
Settings\SSh\Desktop\Copy of Crack2.mdb")

For Each tdf In db.TableDefs
If Left(tdf.Name, 4) <> "MSys" Then
DoCmd.TransferDatabase acExport, "Microsoft Access",
strDBName, acTable, tdf.Name, tdf.Name
End If

Next tdf
MsgBox "Tables copied OK", vbOKOnly, " "
sExit:
Set db = Nothing
Exit Sub
E_Handle:
MsgBox Err.Description, vbOKOnly, Err.Number
Resume sExit
End Sub
Nov 12 '05 #1
2 7162
The DoCmd.TransferDatabase is working in your "local" database, not in the
one you opened using the OpenDatabase statement. That means it doesn't know
anything about the TableDef objects you're finding in your loop.

You could try using Automation. Take a look at
http://support.microsoft.com/?id=210111 If you look at the code associated
with the Method 3 example, you'll see how to use DoCmd and have it apply to
the other database.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(No private e-mails, please)

"Sam" <Do*********@hotmail.com> wrote in message
news:28**************************@posting.google.c om...
Hey,

Basically the code below, should first create a database and then copy
the tables from one external database to this newly created database.
At the moment I am using a third access database file to perform this
task, (I would code it in VB, but we don't currently own a version).
This code works a treat if you copy the CurrentDB where the code is
running to a new database, but I need the code to access another
database, the code I have used is below. As you can see I have
replaced the CurrentDB with the necessary path name. The error I get
though is...

The Microsoft Jet database engine could not find the object
'TableNameInHere'. Make sure the object exists and that you spell its
name and the path name correctly.

I understand the problem but as it works using CurrentDB i'm stuck Any
help is greatly appreciated,

Cheers

Sam

Code Is here

Sub sExport(strDBName As String)
On Error GoTo E_Handle
Dim db As DAO.Database
Dim tdf As DAO.TableDef
If Dir(strDBName) <> "" Then Kill strDBName
Set db = DBEngine(0).CreateDatabase(strDBName, dbLangGeneral)
db.Close
Set db = DBEngine.OpenDatabase("C:\Documents and
Settings\SSh\Desktop\Copy of Crack2.mdb")

For Each tdf In db.TableDefs
If Left(tdf.Name, 4) <> "MSys" Then
DoCmd.TransferDatabase acExport, "Microsoft Access",
strDBName, acTable, tdf.Name, tdf.Name
End If

Next tdf
MsgBox "Tables copied OK", vbOKOnly, " "
sExit:
Set db = Nothing
Exit Sub
E_Handle:
MsgBox Err.Description, vbOKOnly, Err.Number
Resume sExit
End Sub

Nov 12 '05 #2
Sam
Hey Douglas,

Thanks for that I'll have a browse through, currently I have managaed
to set it up so that all the tables are copied to the third database
and back out again, not to efficient but it works for now,

Cheers

Sam

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message news:<ro**********************@news01.bloor.is.net .cable.rogers.com>...
The DoCmd.TransferDatabase is working in your "local" database, not in the
one you opened using the OpenDatabase statement. That means it doesn't know
anything about the TableDef objects you're finding in your loop.

You could try using Automation. Take a look at
http://support.microsoft.com/?id=210111 If you look at the code associated
with the Method 3 example, you'll see how to use DoCmd and have it apply to
the other database.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(No private e-mails, please)

"Sam" <Do*********@hotmail.com> wrote in message
news:28**************************@posting.google.c om...
Hey,

Basically the code below, should first create a database and then copy
the tables from one external database to this newly created database.
At the moment I am using a third access database file to perform this
task, (I would code it in VB, but we don't currently own a version).
This code works a treat if you copy the CurrentDB where the code is
running to a new database, but I need the code to access another
database, the code I have used is below. As you can see I have
replaced the CurrentDB with the necessary path name. The error I get
though is...

The Microsoft Jet database engine could not find the object
'TableNameInHere'. Make sure the object exists and that you spell its
name and the path name correctly.

I understand the problem but as it works using CurrentDB i'm stuck Any
help is greatly appreciated,

Cheers

Sam

Code Is here

Sub sExport(strDBName As String)
On Error GoTo E_Handle
Dim db As DAO.Database
Dim tdf As DAO.TableDef
If Dir(strDBName) <> "" Then Kill strDBName
Set db = DBEngine(0).CreateDatabase(strDBName, dbLangGeneral)
db.Close
Set db = DBEngine.OpenDatabase("C:\Documents and
Settings\SSh\Desktop\Copy of Crack2.mdb")

For Each tdf In db.TableDefs
If Left(tdf.Name, 4) <> "MSys" Then
DoCmd.TransferDatabase acExport, "Microsoft Access",
strDBName, acTable, tdf.Name, tdf.Name
End If

Next tdf
MsgBox "Tables copied OK", vbOKOnly, " "
sExit:
Set db = Nothing
Exit Sub
E_Handle:
MsgBox Err.Description, vbOKOnly, Err.Number
Resume sExit
End Sub

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Unregistered | last post by:
I'm making an Intranet site for someone who is not very familiar wit making websites, thus I would like to make it as simple as possible fo her when she needs to update it. The intranet site...
5
by: Scott Tilton | last post by:
I am having a terrible time getting this to work. I am hoping someone out there can help me with very specific code examples. I am trying to get the linked tables in my Access 97 database to be...
2
by: David | last post by:
Hi, We have an internal network of 3 users. Myself & one other currently have individual copies of the front-end MS Access forms and via our individual ODBC links we have used the: File > Get...
6
by: ats | last post by:
I have a table that contains the database names of external databases. Each one of these external databases contain a table (which has the same structure) that I would like to query together as one...
2
by: Helen | last post by:
Hi I am trying to compile a package of avi to mpeg1 C source codes But I got the link error I searched actually my VFW.h and Vfw32.lib are all in the directory what should I do thanks a lot...
3
by: Leith Bade | last post by:
I have been trying to use the new Visual C++ Toolkit 2003 with the VC6 IDE I set up the executable, inlcude, and library directories to point to the new compilers I had to fix a few errors in the...
7
by: Lisa | last post by:
I have an Access 2000 application that uses the following function to re-link my tables when I switch from my Current back end to a Dummy back end. I also use it to refresh my links. Function...
2
by: Angus | last post by:
Hello I am using some classes from a third party and have included them in my projecxt and am compiling and linking with them. Everything compiles ok but I get these link errors: I added...
6
by: info | last post by:
hello all, if anyone out there could help me i would really appreciate it. i am very much a novice coder. I have a site we are building and we have created a section in the admin area to allow the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.