Microsoft Office Online
Sign in to My Office Online (What's this?) | Sign in

 
 
Microsoft Office Word
Search
Search
 
Check for updates: (c) Microsoft
Office downloads
 
 
 
Warning: You are viewing this page with an unsupported Web browser. This Web site works best with Microsoft Internet Explorer 6.0 or later, Firefox 1.5, or Netscape Navigator 8.0 or later. Learn more about supported browsers.

Email this linkEmail this link Printer-Friendly VersionPrinter-Friendly Version Bookmark and ShareShare
Field codes: Database field
 

{ DATABASE [Switches ] }

Inserts the results of a database query (query: A means of finding all the records stored in a data source that fit a set of criteria you name. Queries can contain operators, quotation marks, wildcard characters, and parentheses to help focus your search.) in a Microsoft Word table. If the number of columns is 62 or greater, the DATABASE field inserts the results of a query in columns separated by tabs. The DATABASE field contains all the information needed to connect to a database and perform a Structured Query Language (SQL) (Structured Query Language (SQL): A database query and programming language widely used for accessing, querying, updating, and managing data in relational database systems.) query. You update the field to query the database again.

A DATABASE field is inserted by the Insert Database Button image button on the Database toolbar (toolbar: A bar with buttons and options that you use to carry out commands. To display a toolbar, press ALT and then SHIFT+F10.).

Security  When you connect to a data source, be sure that your password is not readable by others. For example, do not store it where it is readable as plain text, such as in a macro. Do not send it on the Internet unless you use the Secure Sockets Layer (SSL) protocol, which encrypts data. You can tell whether a Web address uses SSL if the address starts with "https" instead of "http."

ShowSwitches

\b "Sum"

Specifies which attributes of the format set by the \l switch to apply to the table. If the \l switch is blank, the \b switch value must be 16 (AutoFit). Include the sum of any combination of the following values to specify the value for the switch.

For example, the switches \l "3" \b "11" apply only the borders, shading, and color attributes of the table format set by the \l switch.

This value Specifies
0 None
1 Borders
2 Shading
4 Font
8 Color
16 AutoFit
32 Heading Rows
64 Last Row
128 First Column
256 Last Column

\c "ConnectInfo"

Specifies a connection to the data. For example, a query to a Microsoft Access database might contain the connection instructions \c "DSN=MS Access Databases; DBQ=C:\\Data\\Sales93.mdb; FIL=RedISAM;".

\d "Location"

The path (path: The route that the operating system uses to locate a folder or file; for example, C:\House finances\March.doc.) and file name of the database. Used for all database queries except a query to an SQL database table using ODBC (Open Database Connectivity (ODBC): A standard method of sharing data between databases and programs. ODBC drivers use the standard Structured Query Language (SQL) to gain access to external data.). Use double backslashes in the path — for example, "C:\\Data\\Sales94.mdb".

\f "StartNumber"

Specifies the record number of the first data record (data record: A complete set of related information that corresponds to one row of information in the data source. All information about one client in a client mailing list is an example of a data record.) to insert — for example, \f "2445".

\h

Inserts field names from the database as column headings in the resulting table.

\l "Format#"

Applies a format from the Table AutoFormat dialog box (Table menu) to the result of the database query. The number Format# is determined by the table format you select in the dialog box. If this switch is used and the \b switch doesn't specify the table attributes, Word inserts an unformatted table.

\o

Inserts data at the beginning of a merge.

\s "SQL"

SQL instructions. You must insert a backslash (\) before each quotation mark in the instructions. For example, instructions for a Microsoft Access database might be as follows:
"select * from \s \"Customer List\"".

\t "EndNumber"

Specifies the record number of the last data record to insert — for example: \t "2486".

ShowExamples

The following field results from a query to a Microsoft Access database through ODBC (Open Database Connectivity (ODBC): A standard method of sharing data between databases and programs. ODBC drivers use the standard Structured Query Language (SQL) to gain access to external data.) using the Database command:

{ DATABASE \d "C:\\Data\\Sales93.mdb" \c "DSN=MS Access Database; DBQ=C:\\Data\\Sales93.mdb; FIL=RedISAM" \s "select * from \"Customer List\" " \f "2445" \t "2486" \l "2" }

advertisement