Section 12.4.  Exporting other objects

Prev don't be afraid of buying books Next

12.4. Exporting other objects

In addition to exporting data directly from tables, you can also export queries, forms and reports from Access. This is useful when you want a different view of the data from what the table provides.

12.4.1 Exporting queries

Exporting a query is useful if you don't want to export all the columns of a table, if you want to join the tables on relationships other than the key relationships, or if you want to specify complex conditions that filter the exported rows.

Our orders database has a query named ORDERS WITH MENS DEPT ITEMS, shown in Figure 12-10.

Figure 12-10. A query on the orders database




The query selects all the orders, along with their item information, that contain a product whose department is "MEN". We can export the results of this query using the exact same export procedure we used for tables. The result is the XML document shown in Example 12-4.

Example 12-4. Exported query data (ORDERS WITH MENS DEPT ITEMS.xml)
 <?xml version="1.0" encoding="UTF-8"?> <dataroot xmlns:od="urn:schemas-microsoft-com:officedata"           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"           xsi:noNamespaceSchemaLocation=           "ORDERS%20WITH%20MENS%20DEPT%20ITEMS.xsd"           generated="2003-08-26T18:22:43">   <ORDERS_x0020_WITH_x0020_MENS_x0020_DEPT_x0020_ITEMS>     <ORD_NUM>1001</ORD_NUM>     <PROD_NUM>219</PROD_NUM>     <NAME>Cotton Rugby Shirt</NAME>     <DEPT>MEN</DEPT>   </ORDERS_x0020_WITH_x0020_MENS_x0020_DEPT_x0020_ITEMS>   <ORDERS_x0020_WITH_x0020_MENS_x0020_DEPT_x0020_ITEMS>     <ORD_NUM>1001</ORD_NUM>     <PROD_NUM>334</PROD_NUM>     <NAME>Wool Fisherman&apos;s Sweater</NAME>     <DEPT>MEN</DEPT>   </ORDERS_x0020_WITH_x0020_MENS_x0020_DEPT_x0020_ITEMS> </dataroot> 

Each row is represented by an element whose element-type name matches the query name. In this case, since our query name has spaces, and spaces are not allowed in XML names, each space is replaced by the string _x0020_.

The row element has a child element for every column returned by the query. The element-type names are the column names from the tables used in the query. To change them, in the Field box of the query design view, you can specify an alias as a prefix, followed by a colon and a space as shown in Figure 12-11.

Figure 12-11. Using column aliases for queries




When the query is exported, the prefixes –A, B, C and D– are used as the element-type names.

12.4.2 Exporting forms

It is also possible to export the data behind a form as XML. This is useful if a user working with the form wants to export a single record. Our orders database contains a form named ORDERS, shown in Figure 12-12.

Figure 12-12. A form in the orders database




The structure of the exported data is exactly the same as that of data exported directly from the ORDERS table, as shown in Example 12-3. The export doesn't leave out the items that are not displayed on the form, nor does it structure the data any differently. You can, however, choose to only export the current order record by specifying that option on the Data tab of the Export XML dialog.

When saving a presentation with the form data, the HTML page that is generated has the same look and feel as the form, including the colors, fonts and general layout. You can also choose to export the images by selecting Put images in and specifying a directory. This will include all images, including any background pattern, that appear on the form.

Unfortunately, only the main form is displayed, and not the subforms. In our example, only the order header information is displayed, and not the individual items within an order. This limits the usefulness of the presentation somewhat.

12.4.3 Exporting Access project objects

In addition to exporting data from Access databases, it is possible to export data from Access projects. Access projects, files with the extension .adp, allow a user to access and report on Microsoft SQL Server data using the front-end tools of Access. XML data can be generated from an Access project table, view or form, in exactly the same way as it is generated from an Access database table or form.

If you are already using an Access project to manipulate or report on SQL Server data, this can be a convenient way to extract data. XML data can also be exported directly from SQL Server.

Amazon


XML in Office 2003. Information Sharing with Desktop XML
XML in Office 2003: Information Sharing with Desktop XML
ISBN: 013142193X
EAN: 2147483647
Year: 2003
Pages: 176

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net