Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    importing tables from external DB (Access 2000)

    importing tables from external Db by code
    ===

    I have a very good routine for linking tables to an external database.This is not a mine function,i have copied it from a book.
    I am linking only the user tables,not system tables,,through the definition
    Tbl.Attributes = 0.
    What i want is to carry out an import instead of linking the tables. After several attempts i had no success,it waws a difficult job.Can someone help me in modifying the code for linking the tables into a code for importing the tables?
    The working code for linking which i want to modify is the following

    Public Function LinkAllTables(dbName)
    Dim FrontDB As DAO.Database,BackDB As DAO.TableDef
    Set FrontDB = CurrentDB
    Set BacikDB = OpenDatabase(dbName)
    For each Tbl in BackDB.TableDefs
    If Tbl.Attributes = 0 Then
    Set Lnk = FrontDB.CreateTableDef(Name:=Tabl.Name)
    Lnk.SourceTableName = Tbl.Name
    Lnk.Connect = " ; DATABASE = " & BackDB.Name
    FrontDB.TableDefs.AppendLnk
    End If
    Next
    End Function

    Can someone help me in modifying the above code so that it imports the use4r defined tables instead of linking them?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: importing tables from external DB (Access 2000)

    Lookup up TransferDatabase in on-line help. The statement will be something like this for each table:

    <pre> DoCmd.TransferDatabase TransferType:=acImport, _
    DatabaseType:="Microsoft Access", _
    DatabaseName:=dbName, _
    ObjectType:=acTable, _
    Source:=strTblName, _
    Destination:=strTblName</pre>


    Where strTblName is a variable holding the name of each table you want to import.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •