TransferDatabase Action

Description

You can use the TransferDatabase action to import or export data between the current Microsoft Access database and another database. You can also link a table to the current Microsoft 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.

Setting

The TransferDatabase action has the following arguments.

Action argument

Description

Transfer Type

The type of transfer you want to make. Select Import, Export, or Link in the Transfer Type box in the Action Arguments section of the Macro window. The default is Import.

Database Type

The type of database to import from, export to, or link to. You can select Microsoft Access or one of a number of other database types in the Database Type box. The default is Microsoft Access.

The database types shown in the Database Type argument depend on how you've set up Microsoft Access. Not all database types are installed by default. If the database type you want to use for importing, exporting, or linking isn't available, run the Microsoft Access Setup program, click the Add/Remove option, select the Data Access and ActiveX Controls option in the dialog box and click the Change Option button, and then select the database type you want to install from the Database Drivers box and click the Change Option button again. Some database drivers are only included in the Office 97 ValuPack (additionally, the ValuPack includes all of the database drivers available from Microsoft Access Setup).

Database Name

The name of the database to import from, export to, or link to. Include the full path. This is a required argument.

For types of databases that use separate files for each table, such as FoxPro, Paradox, and dBASE, enter the directory containing the file. Enter the file name in the Source argument (to import or link) or the Destination argument (to export).


(continued)

For ODBC databases, type the full Open Database Connectivity (ODBC) connection string. To see an example of a connection string, link an external table to Microsoft Access by pointing to Get External Data on the File menu and clicking Link Tables. Open the table in Design view and view the table properties. The text in the Description property setting is the connection string for this table.

For more information on ODBC connection strings, see the Help file or other documentation for the ODBC driver of this type of ODBC database.

Object Type

The type of object to import or export. If you select Microsoft Access for the Database Type argument, you can select Table, Query, Form, Report, Macro, or Module in the Object Type box. If you select any other type of database, or if you select Link in the Transfer Type box, this argument is ignored. The default is Table.

If you are exporting a select query to a Microsoft Access database, select Table in this argument to export the result set of the query, and select Query to export the query itself. If you are exporting a select query to another type of database, this argument is ignored and the result set of the query is exported.

Source

The name of the table, select query, or Microsoft Access object that you want to import, export, or link. For some types of databases, such as FoxPro, Paradox, or dBASE, this is a file name. Include the file name extension (such as .dbf) in the file name. This is a required argument.

Destination

The name of the imported, exported, or linked table, select query, or Microsoft Access object in the destination database. For some types of databases, such as FoxPro, Paradox, or dBASE, this is a file name. Include the file name extension (such as .dbf) in the file name. This is a required argument.

If you select Import in the Transfer Type argument and Table in the Object Type argument, Microsoft Access creates a new table containing the data in the imported table.

If you import a table or other object, Microsoft Access adds a number to the name if it conflicts with an existing name. For example, if you import Employees and Employees already exists, Microsoft Access renames the imported table or other object Employees1.

If you export to a Microsoft Access database or another database, Microsoft Access automatically replaces any existing table or other object that has the same name.

Structure Only

Specifies whether to import or export only the structure of a database table without any of its data. Select Yes or No. The default is No.


Remarks

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

In Microsoft Access 97, if you import a table from another Microsoft 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.

If the database you're accessing requires a password, a dialog box appears when you run the macro. Type the password in this dialog box.

Note You can only import and export data between Microsoft Access and FoxPro version 3.0 databases. You can't link to tables in these FoxPro databases.

The TransferDatabase action is similar to pointing to Get External Data or Save As/Export on the File menu of the Database window and clicking Import or Link Tables. You can use these commands to select a source of data, such as Microsoft Access or a type of database, spreadsheet, or text file. If you select a database, one or more dialog boxes appear in which you select the type of object to import or export (for Microsoft Access databases), the name of the object, and other options, depending on the database you are importing from or exporting or linking to. The arguments for the TransferDatabase action reflect the options in these dialog boxes.

If you want to supply index information for a linked FoxPro or dBASE table, first link the FoxPro or dBASE table by pointing to Get External Data on the File menu and clicking Link Tables, then specify the indexes in the dialog boxes for this command. Microsoft Access stores the index information in a special information (.inf) file, located in the Office folder (the path is C:\Program Files\Microsoft Office\Office). You can then delete the link to the linked table. The next time you use the TransferDatabase action to link this FoxPro or dBASE table, Microsoft Access uses the index information that you've specified.

Note If you query or filter a linked table, the query or filter is case-sensitive.

To run the TransferDatabase action in Visual Basic, use the TransferDatabase method of the DoCmd object.

See Also

Connect property ("DAO Language Reference"), CopyObject action, OutputTo action, Save action, SendObject action, TransferDatabase method, TransferSpreadsheet action, TransferText action.