DoCmd.TransferDatabase method (Access)
The TransferDatabase method carries out the TransferDatabase action in Visual Basic.
expression.TransferDatabase (TransferType, DatabaseType, DatabaseName, ObjectType, Source, Destination, StructureOnly, StoreLogin)
expression A variable that represents a DoCmd object.
|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:
|DatabaseName||Optional||Variant||A string expression that's the full name, including the path, 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.|
You can 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.
You can also use ActiveX Data Objects (ADO) to create a link by using the ActiveConnection property for the Recordset object.
The following example imports the NW Sales for April report from the Access database NWSales.mdb into the Corporate Sales for April report in the current database.
DoCmd.TransferDatabase acImport, "Microsoft Access", _ "C:\My Documents\NWSales.mdb", acReport, "NW Sales for April", _ "Corporate Sales for April"
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"
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.