?
Solved

Import Tables From one Database to the Other!

Posted on 2003-03-20
2
Medium Priority
?
165 Views
Last Modified: 2010-05-01
Hi All!

i use this code to create link between databases!

i got this code from vbcode.com

can anybody tell me that hw can i do the import tables function??

even i dont require in same format........but what ever easier and effective!

Dim dbname As String
Dim Eng As String
Dim DESIGNREPORTS As Database
Dim engcn As ADODB.Connection
Dim engcat As ADOX.Catalog
Dim engtbl As ADOX.Table
Dim tablename As String
Dim suitecat As ADOX.Catalog
Dim suitecn As ADODB.Connection
Dim suitetbl As ADOX.Table
Dim designcat As ADOX.Catalog
Dim designcn As ADODB.Connection
Dim designtbl As ADOX.Table


Private Sub Command2_Click()
dbname = "D:\My Documents\Access Files\Budget.mdb"
Eng = "D:\My Documents\Access Files\Copy of db1.mdb"
Set engcn = New ADODB.Connection
   engcn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Eng & ""
   
   Set suitecn = New ADODB.Connection
   suitecn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbname & ""
   
   Set engcat = New ADOX.Catalog
   Set suitecat = New ADOX.Catalog
   
   
    engcat.ActiveConnection = engcn
    suitecat.ActiveConnection = suitecn
    For Each suitetbl In suitecat.Tables
    If suitetbl.Type = "TABLE" Then
    Set engtbl = New ADOX.Table
    tablename = suitetbl.Name
    engtbl.Name = tablename
    Set engtbl.ParentCatalog = engcat
    engtbl.Properties("Jet OLEDB:Link Datasource") = dbname
    engtbl.Properties("Jet OLEDB:Remote Table Name") = tablename
    engtbl.Properties("Jet OLEDB:Create Link") = True
    engcat.Tables.Append engtbl
    End If
    Next
   
End Sub
0
Comment
Question by:Sankar_V
2 Comments
 

Accepted Solution

by:
makman earned 100 total points
ID: 8179245
Hi SankarV
you can use a TransferDatabase Method.
Syntax below:
TransferDatabase(TransferType, DatabaseType, DatabaseName, ObjectType, Source, Destination, StructureOnly, StoreLogin)
TransferType  Optional AcDataTransferType.

AcDataTransferType can be one of these AcDataTransferType constants.
acExport
acImport default
acLink
If you leave this argument blank, the default constant (acImport) is assumed.

Note   The acLink transfer type is not supported for
 
Refrence Link:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac10/html/acmthactTransferDatabase.asp
Regards,
Makman
0
 
LVL 1

Author Comment

by:Sankar_V
ID: 8179772
Thanks makman!

Thanks for ur reference!

I got the result which i want!

Thanks a lot!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…
Suggested Courses

578 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