Applecore Pages on Microsoft Access

Creating Static HTML files from an Access database

Normally, when you use an Access database and the internet, you would be using some sort of dynamic pages, probably Active Server Pages (ASPs). However, there are times when you might need to output static pages. For example, one reason might be to create a standalone web application that can be distributed via CD-ROM. There are various html compilers, but they won't work with ASP pages. Below is some sample code to get you started with this task:

Sub sCreateStaticHTMLFiles()
    Dim db As Database
    Dim rs As Recordset
    Dim strHTMLFile As String
    Set db = DBEngine(0)(0)
    Set rs = db.OpenRecordset("tblName")
    Do
        strHTMLFile = "C:\PathToFolder\"& Format(rs!PKField, "000") & ".htm"
        Open strHTMLFile For Output As #1
        Print #1,"</TABLE>"
        Print #1,"<TABLE BORDER=1><TR>"
        Print #1,"<TD>" & rs!Field1 & "</TD></TR>"
        Print #1, Nz("<TR><TD>"+ rs!Field2 + "</TD></TR>", "")
        Print #1, "<TR><TD><IMG SRC=" & Chr(34) & rs!PicturePathField & Chr(34) &"></TD></TR>"
        Print #1,"</TABLE>"
        Close #1
        rs.MoveNext
    Loop Until rs.EOF
    Exit Sub
End Sub

By storing images in Access as just the paths to the files, it becomes very easy to include these in the HTML pages. If you have created a database that does have the images included as OLE objects, then Stephen Lebans has various databases on his site that allow you to extract these images to files.

Top

 


HOME | NEW | TABLES | QUERIES | FORMS | REPORTS | GENERAL | API | DOWNLOADS | TUTORIAL | RESOURCES
E-MAIL
Copyright & Disclaimer

 

Last modified at 06/06/2006 14:55:44