| Applies to |
Microsoft Office Access 2003 Microsoft Access 2002 |
There are several ways to make your Access data available on the Web. Usually, Access displays more than one record per Web page. For example, when you create a data access page, you can browse and modify all records in the record set from one Web page. Or, when you output a datasheet to an HTML or XML file, all the records are formatted as one HTML table. However, there are times when you want to output one HTML file per record.
Why output one HTML file per record in an Access database?
To illustrate, let's say each record in a Products table contains all the data you need to form the contents of one Web page. Each week, you update an online products catalog. First, you create one HTML file for each product. Then, you load these pages into a Microsoft FrontPage® Web site. Finally, users browse an alphabetical Table of Contents frames page used to navigate or locate the individual product Web pages. Displaying more than one record per Web page would not work in this case because it would interfere with the navigation scheme.
How many ways in Access can I output one HTML file per record?
In Access, there are two ways you can output a separate HTML file for each record:
- Create a report that displays one record per page, and then output the report as an HTML file.
- Use the PRINT statement in Microsoft Visual Basic® for Applications (VBA) to enumerate through a recordset, format each field as HTML tags, and then output each record to an HTML file.
Use a report to output one HTML file per record
- Create a report based on the desired record source. You can use AutoReport, the Report wizard, or report Design view. For more information, see Access Help.
- Arrange the fields of data in a columnar layout in the Detail section of the report. The AutoReport and Report wizards can automatically do this for you.
- Force the report to print each record on a separate page by setting the ForceNewPage property to After Section. For more information, see Access Help.
- Save the report.
- Output the report to HTML format. By default, Access automatically creates a separate HTML file for each page using the file name and a suffix; for example, Products.html, ProductsPage1.html, ProductsPage2.html, and so on. For more information on exporting reports to HTML, see Access Help.
Tip Access automatically adds text navigation buttons at the bottom of each Web page. If you don't want Access to insert the text navigation buttons on each page, you can create your own HTML template file. For more information on HTML template files and creating Web pages, see Access Help.
This approach works well if you can easily fit the fields of data on one report page. If a field contains a hyperlink data type, Access even creates an HTML Anchor tag so the URL in the HTML file is active. However, if a text or memo field contains HTML tags, Access does not render the HTML when it outputs the report to HTML: The angle brackets are converted to string literals. Also, when you output a report to HTML format, images are ignored.
Use the VBA PRINT statement to output one HTML file per record
Using a report to output one HTML file per record may not work for you. For example, you may not be able to fit all the fields of data on one page of a report, you have stored HTML tags in a memo field and want the data rendered as HTML, you want to output images on the Web page, or you want to use your own file naming scheme. In this case, you can create a Microsoft Visual Basic® for Applications (VBA) program that enumerates through the record set and uses the PRINT statement to output each record as a separate HTML file.
For more information on ADO code examples and the PRINT statement, see Access Visual Basic Help.
For more information about programming in Access, visit the Office Developer Center on the Microsoft Developer Network (MSDN).