In This SiteIn This Section
|
Take Your Web Site to New LevelsLine Breaks in Memo Fields Do Not Show Up When Viewed OnlineOne of the challenges of working with databases for your web pages has to do with the simple fact that some times they look at things differently. Take line breaks for example. When you enter text into a memo field into an Access database and enter a carriage return, Access stores two things. Your lines of text are separated by a carriage return followed by a line feed. Usually, this is abbreviated to CrLf. Unfortunately, HTML code ignores CrLf because according to the HTML specification, line feeds are considered to be "white space" and as such are ignored. This can mess up a carefully designed page as you may have long field values that contain many carriage returns. Solve the Problem in AccessWhen I first discovered this limitation, I found a work around in my Access database. Whenever I needed a carriage return to show up in my web page, I simply added the HTML code for a line break <br> as I entered the data into the Access form OR the FrontPage form that was submitted to the database. You will see the technique used in the following image.
Create a Database Results Wizard based upon the table. It should look like the following:
Once you create your Database Results Wizard (DRW), double-click the Details field to open the field properties.
By selecting the "Contains HTML" option, the web page takes the line break code and translates that to a line break in the web page. This DOES work, but it is not always practical to force your users to learn HTML coding. It's also unnecessary. With a little FrontPage Magic, you can have FrontPage automatically replace all the Access generated CrLf combinations with the HTML <br> code. This allows you to work with your Access data without having to think about translating every carriage return into an HTML line break. Convert CrLf to <br> on a Field by Field BasisBefore you attempt this example, be sure to make a backup copy of the web page your are planning to alter. Once you do this, you will no longer see the field name in FrontPage's normal view. For this reason, you should save this procedure for the last stage of your page development. Once you are finished with all the design and layout, then it's a simple matter to make this final change prior to taking your page live. For this example, I've created a simple database table to illustrate the problem. In this table, I've created three fields: Name: Text Field I've added just a single record. The Details field is three lines long. To see the problem, I've created a simple DRW to display all three fields. Name: Bill Smith Company: Bill Smith Enterprises Details: This is the first line. This is the second line. This is the third line. In this example, you'll see that the Details field, despite having three lines of data, displays as only a long single line. To correct this, select the field name <<Details>> and then switch to the HTML pane. You will see that it has already selected the code that will be used to connect to the database and retrieve the Details field. It will resemble the following:
Here comes the scary part. Delete the highlighted code and replace it with with the following: <%=Replace(FP_FieldVal(fp_rs,"Details"),vbCrLf,"<br>")%> Don't forget: If you copy this to the clipboard, you'll need to first paste it into notepad. Then copy it from notepad in order to paste it into the HTML pane. Simply translated, this technique tells FrontPage to display the field named Details, but to replace all instances of the CrLf with an HTML <br>. Name: Bill Smith Company: Bill Smith Enterprises Details: This is the first line.This is the second line. This is the third line. Now, when you view the page online, the page breaks will display correctly. These tutorials are part of an upcoming training course called "FrontPage Magic - How To Create A Database Driven Website For Non-Programmers". Stay tuned for more details on this exciting new product. Send your tips to .
|