# Visual Basic > Visual Basic FAQs >  [FAQ's: OD] How do I import/copy a database object from another database?

## RobDog888

There are two easy methods for transfering/copying database objects between databases.

The first is the .CopyObject method of the DoCmd object:
_expression_.CopyObject DestinationDatabase, NewName, SourceObjectType, SourceObjectName

_DestinationDatabase_: [Optional] Variant. The first argument is the path and file name for the database you want to copy the object into. To select the current database, leave this argument blank.

_NewName_: [Optional] The new String name of the object if you want to perform a renaming. To keep the original name then just leave this argument blank.

_SourceObjectType_: [Optional] The type of Access Object to be copied...
  acDataAccessPage 
  acDefault default 
  acDiagram 
  acForm 
  acFunction 
  acMacro 
  acModule 
  acQuery 
  acReport 
  acServerView 
  acStoredProcedure 
  acTable  

_SourceObjectName_: [Optional] String. The source name of the object to be copied.



*Access 2003 VBA Code Example:*

VB Code:
Public Sub ImportTable()
    'Turn off any warning messages
    Application.DoCmd.SetWarnings False
    Application.DoCmd.CopyObject "DestinationDatabase", "NewName", acTable, "SourceObjectName"
    'Turn warning messages back on
    Application.DoCmd.SetWarnings True
End Sub

The other is the .TransferDatabase method also of the DoCmd object:
_expression_.TransferDatabase(TransferType, DatabaseType, DatabaseName, ObjectType, Source, Destination, StructureOnly, StoreLogin)

_TransferType_: [Optional] Integer Constant.
  acExport
  acImport _default_
  acLink 

_DatabaseType_: [Optional] Variant. Name of the type of database used for the import.
  Microsoft Access _default_
  Jet 2.x
  Jet 3.x
  dBase III
  dBase IV
  dBase 5.0
  Paradox 3.x
  Paradox 4.x
  Paradox 5.x
  Paradox 7.x
  ODBC Databases 
  WSS

_DatabaseName_: [Optional] Variant. Full name and filepath of the database being used for the transfer type.

_ObjectType_: [Optional] Integer Constant. The type of object whose data you want to import, export, or link with. 
  acDataAccessPage 
  acDefault 
  acDiagram 
  acForm 
  acFunction 
  acMacro 
  acModule 
  vacQuery 
  acReport 
  acServerView 
  acStoredProcedure 
  acTable _default_

_Source_: [Optional] Variant. Source name of the object to be transfered or linked to.

_Destination_: [Optional] Variant. The name of the imported, exported, or linked object in the destination database.

_StructureOnly_: [Optional] Variant. False (default). True to import or export only the structure of a database table and False to import or export the structure of the table and its data.

_StoreLogin_: [Optional] Variant. True to store the login identification (ID) and password for an ODBC database in the connection string for a linked table from the database. If you do this, you don't have to log in each time you open the table. Use False if you don't want to store the login ID and password. If you leave this argument blank, the default (False) is assumed. This argument is available only in Visual Basic.



*Access 2003 VBA Code Example:*

VB Code:
Option Explicit
 Public Sub ImportTable()
    'Turn off any warning messages
    Application.DoCmd.SetWarnings False
    Application.DoCmd.TransferDatabase acImport, "Microsoft Access", "D:\DB2ImportFrom.mdb", acTable, "Table1", "ImportedTableName", False
    'Turn warning messages back on
    Application.DoCmd.SetWarnings True
End Sub

----------

