Report to HTML

C

CD Tom

I have reports that after they are created I put them into an html format.
The problem is I can't seem to get them to line up like the actual report.
I've doubled checked to make sure that no fields are touching on the access
report, but to no avail, does anybody have any ideas as to a good way to do
this.
Thanks for all the help.

Tom
 
A

Allen Browne

Access doesn't do a good job of exporting reports to HTML.
Is there any chance of exporting a query instead? Use:
DoCmd.TransferText acExportHTML, ...

What I personally tend to do is to write the export in VBA code, so it gets
the heading, titles, styles, table widths, comments etc, that I want. As an
example, this page is done that way:
http://allenbrowne.com/FuncIndex.html

Abbreviated, the code is like this:

Public Function ExportFuncList() As String
Dim rs As DAO.Recordset
Dim strSql As String
Dim i As Integer
Const strcFileName = "C:\MyFolder\FuncIndex.html"

'***************************
'Print the HTML header, and open the table.
'***************************
Open strcFileName For Output As #1
Print #1, "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01
Transitional//EN"" ""http://www.w3.org/TR/html4/loose.dtd"">"
Print #1, "<html>"
Print #1, "<head>"
'...
Print #1, "</head>"
Print #1, "<body>"
Print #1, "<h3><a name=""Top"">Microsoft Access: Index to VBA
Functions</a></h3>"

'***************************
'Loop through the function, adding rows to the HTML table.
'***************************
strSql = "SELECT tblProc.ProcName, ...
Set rs = DBEngine(0)(0).OpenRecordset(strSql)
Do While Not rs.EOF
i = i + 1
Print #1, " <tr><td>" & rs!ProcName & "</td>" & vbCrLf & _
" <td>" & rs!Descrip & "</td>" & vbCrLf & _
" <td><a href=""" & rs!PageFilename & ("#" + rs!SubAddress) & _
"""><font size=""1"">" & rs!PageName & "</font></a></td></tr>"
rs.MoveNext
Loop
rs.Close
Set rs = Nothing

'***************************
'Close the table, and complete the HTML.
'***************************
Print #1, "</table>"
Print #1, "</body>"
Print #1, "</html>"
Close #1

ExportFuncList = strcFileName & " written " & Now()
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top