Access line breaks are not displayed in FrontPage Database Results Region (269599)



The information in this article applies to:

  • Microsoft Office FrontPage 2003
  • Microsoft FrontPage 2002
  • Microsoft FrontPage 2000

This article was previously published under Q269599

SYMPTOMS

Text that you expect to appear as separate lines in a Database Results Region appears, instead, as a single unbroken string of characters.

CAUSE

In Microsoft Access, lines of text are separated by a carriage return followed by a line feed, which is often abbreviated as CRLF. When a CRLF combination is displayed in a Web page, a Web browser ignores it, because the HTML specification states that line feeds are ignored as "White Space".

Note See the "More Information" and "References" sections for additional details.

WORKAROUND

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To work around this behavior, replace the CRLF character sequences used by Access with the <BR> tag using Active Server Pages (ASP) code.

Code Sample

Note You may receive an error message if you copy and paste the examples directly from this article to FrontPage. The angle brackets ("<" and ">") may appear as escaped HTML code ("<" and ">"). To work around this behavior, paste the script in a blank Notepad document, and then copy it from Notepad before pasting it into FrontPage.
  1. To create a form page, follow these steps:
    1. Start FrontPage and open a Web site on a Web server that is running Internet Information Services 4.0 or later.
    2. On the File menu, click New, and then click Page.
    3. Select Normal Page from the list of available templates, and then click OK.
    4. On the File menu, click Save As. In the File name box, type FormTest.asp and then click Save.
    5. On the Insert menu, point to Form, and then click Scrolling Text Box.
    6. Right-click the text box. On the shortcut menu, click Form Field Properties.
    7. Make the following changes in the Scrolling Text Box Properties dialog box:
      • Name = Sample
      • Width in characters = 40
      • Number of lines = 10
    8. Click OK to close the Scrolling Text Box Properties dialog box.
    9. Right-click the form. On the shortcut menu, click Form Properties.
    10. In the Form Properties dialog box, select Send to database, and then click Options.
    11. In the Options for Saving Results to Database dialog box, click Create Database. Click OK in each dialog box to return to the page FormTest.asp.
    12. On the toolbar, click Save.
    13. Click Preview in Browser on the FrontPage toolbar.
    14. Click in the text area, and then type the following lines. Press ENTER twice at the end of each of the first two sentences:
      This is a test.
      
      This block of text has three lines.
      
      They are separated by blank lines.
      						
    15. Click the Submit button to submit the information to the database.
    16. Close your Web browser.
  2. To create a display page, follow these steps:
    1. On the FrontPage File menu, point to New, click Page, select Normal Page, and then click OK to create another new blank page. Save the page as DisplayTest.asp.
    2. On the Insert menu, point to Database, and then click Results.
    3. In page 1 of the Database Results Wizard, select FormTest and then click Next.
    4. In page 2, select Results and then click Next.
    5. In page 3, click Edit List.
    6. In the Displayed fields list, remove all fields except Sample, click OK, and then click Next.
    7. In page 4, select List - one field per item from the formatting options and Paragraphs from the list options, and then click Next.
    8. In page 5, select Display all records together, and then click Finish.
    9. Save the page.
    10. Click Preview in Browser on the FrontPage toolbar.
    11. When the page is displayed, the text appears without line breaks.
    12. Close your Web browser.
  3. To implement the workaround, follow these steps:
    1. Open DisplayTest.asp, click <<sample>> and then press DELETE.
    2. Switch to HTML view and locate the HTML code that is similar to the following:
      <p><b>Sample:</b>&#xa0;</p>
      						
    3. Change the HTML code to the following:
      <p><b>Sample:</b>&#xa0;<%=Replace(FP_FieldVal(fp_rs,"Sample"),vbCrLf,"<br>")%></p>
      						
      Note The ASP code FP_FieldVal(fp_rs,"Sample") is FrontPage's code for returning a database column, and <%=Replace(FP_FieldVal(fp_rs,"Sample"),vbCrLf,"<br>")%> is the ASP code to format a database column with all the carriage returns replaced by HTML "line breaks".
    4. On the toolbar, click Save, and then click Preview in Browser.
    5. When the page is displayed, the text appears with line breaks.

MORE INFORMATION

Lines of text are separated in computer programs by a line break, also called an end of line (EOL). This may be a single character or a sequence of characters. The actual characters used may vary between different programs. In Access, the line break sequence is defined as a carriage return followed by a line feed, which is Chr(13) followed by Chr(10) in ASCII and defined as the constant vbCrLf in Visual Basic.

The Hypertext Markup Language (HTML) specification states that "White Space" is to be ignored when a Web browser parses the HTML code for a page. Generally, this "White Space" refers to extra spaces between the words on a page; for example, two spaces after the end of a sentence are truncated to a single space when displayed on a Web page. The HTML specification defines that a line break is to be treated as white space and therefore ignored. When the Database Results Region correctly displays multiline text from a database in the HTML code, the separate lines of text may then appear to be a single line of text.

The HTML specification states that line breaks are represented by the <BR> formatting tag. By using the code presented in this article in your page, you can replace the Access line breaks with the correct HTML tag to accurately represent the text.

REFERENCES

Additional information about HTML is available in the Hypertext Markup Language section of the following World Wide Web Consortium (W3C) Web site:

Modification Type:MajorLast Reviewed:6/18/2005
Keywords:kbprb KB269599