DoCmd.TransferDatabase method (Access)

The TransferDatabase method carries out the TransferDatabase action in Visual Basic.

Syntax

expression.TransferDatabase (TransferType, DatabaseType, DatabaseName, ObjectType, Source, Destination, StructureOnly, StoreLogin)

expression A variable that represents a DoCmd object.

Parameters

Name Required/Optional Data type Description
TransferType Optional AcDataTransferType The type of transfer you want to make.
DatabaseType Optional Variant A string expression that's the name of one of the types of databases that you can use to import, export, or link data. The DatabaseType parameter is required for exporting and link data actions but not required for importing actions. The types or databases are:
  • 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 Database

  • WSS (SharePoint)

DatabaseName Optional Variant A string expression that's the full name, including the path (for WSS, Windows SharePoint Services, the URL), of the database that you want to use to import, export, or link data.
ObjectType Optional AcObjectType The type of object to import or export.
Source Optional Variant A string expression that's the name of the object whose data you want to import, export, or link.
Destination Optional Variant A string expression that's the name of the imported, exported, or linked object in the destination database.
StructureOnly Optional Variant Use True (1) to import or export only the structure of a database table. Use False (0) to import or export the structure of the table and its data. If you leave this argument blank, the default (False) is assumed.
StoreLogin Optional Variant Use True to store the sign-in 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 sign in each time you open the table. Use False if you don't want to store the sign-in ID and password. If you leave this argument blank, the default (False) is assumed. This argument is available only in Visual Basic.

Remarks

Use the TransferDatabase action to import or export data between the current Microsoft Access database or Access project (.adp) and another database. For Access databases, you can also link a table to the current Access database from another database. With a linked table, you have access to the table's data while the table itself remains in the other database.

You can import and export tables between Access and other types of databases. You can also export Access select queries to other types of databases. Access exports the result set of the query in the form of a table. You can import and export any Access database object if both databases are Access databases.

If you import a table from another Access database that's a linked table in that database, it will still be linked after you import it. That is, the link is imported, not the table itself.

The administrator of an ODBC database can disable the feature provided by the SaveLoginId argument, requiring all users to enter the sign-in ID and password each time they connect to the ODBC database.

Note

You can also use ActiveX Data Objects (ADO) to create a link by using the ActiveConnection property for the Recordset object.

Example

The following example imports the Monthly Sales Report from the Access database Northwind.accdb into the Corporate Sales Report in the current database.

DoCmd.TransferDatabase acImport, "Microsoft Access", _ 
    "C:\Users\Public\Northwind.accdb", acReport, "Monthly Sales Report", _ 
    "Corporate Sales Report"

The following example links the ODBC database table Authors to the current database.

DoCmd.TransferDatabase acLink, "ODBC Database", _ 
    "ODBC;DSN=DataSource1;UID=User2;PWD=www;LANGUAGE=us_english;" & _ 
    "DATABASE=pubs", acTable, "Authors", "dboAuthors"

The following example imports a list in SharePoint to a table in the current database:

DoCmd.TransferDatabase acImport, "WSS", _
    "WSS;DATABASE=https://company-my.sharepoint.com/personal/username_domain_com/express;" & _
    "LIST=NameOfListToImport;RetrieveIds=Yes", _
    acTable, , "NameOfLocalTable", False

The following example exports a table in the current database to a list in SharePoint:

DoCmd.TransferDatabase acExport, "WSS", _
    "https://company-my.sharepoint.com/personal/username_domain_com/express", _
    acTable, "NameOfLocalTable", "NameOfListInSharePoint", False

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.