Reports in HTML with Images

P

Patrick Wolf

Hi,

I've created an Access Report with Images (displayed via the Image control).

The images are on the harddrive and in the Format event I assign the correct image path to the image control.

Private Sub GroupHeaderShot_Format(Cancel As Integer, FormatCount As Integer)
Image.Picture = strPath & Me!pstShotImageFileName
End Sub

This works very nice except when I export the Report to HTML.
There is nothing in the html like
<img src="abc.gif">.

Does anyone know how to create Reports with Access and export them to HTML with Image Tags?

Thanks a lot
Patrick
 
A

Arvin Meyer [MVP]

You will have to write the HTML out from code. Here's a sample that Brendan
Reynolds wrote some time ago
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access

Public Function ExportHTML(strRecordsource As String, strFileName As String)
As Boolean

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim intFile As Integer
Dim fld As DAO.Field

Set db = CurrentDb
Set rst = db.OpenRecordset(strRecordsource)
intFile = FreeFile
Open strFileName For Output As intFile
Print #intFile, "<HTML>"
Print #intFile, "<HEAD>"
Print #intFile, "<TITLE>"
Print #intFile, "<Test Export>"
Print #intFile, "</TITLE>"
Print #intFile, "</HEAD>"
Print #intFile, "<BODY>"
Print #intFile, "<TABLE>"
Print #intFile, "<TR>"
With rst
For Each fld In .Fields
Print #intFile, "<TH>" & fld.Name & "</TH>"
Next fld
Print #intFile, "</TR>"
Do Until .EOF
Print #intFile, "<TR>"
For Each fld In .Fields
Print #intFile, "<TD>" & fld.Value & "</TD>"
Next fld
Print #intFile, "</TR>"
.MoveNext
Loop
.Close
End With
Print #intFile, "</TABLE>"
Print #intFile, "</BODY>"
Print #intFile, "</HTML>"
Close intFile

Set rst = Nothing
db.Close
Set db = Nothing

ExportHTML = True

End Function

--
Brendan Reynolds


Hi,

I've created an Access Report with Images (displayed via the Image control).

The images are on the harddrive and in the Format event I assign the correct
image path to the image control.

Private Sub GroupHeaderShot_Format(Cancel As Integer, FormatCount As
Integer)
Image.Picture = strPath & Me!pstShotImageFileName
End Sub

This works very nice except when I export the Report to HTML.
There is nothing in the html like
<img src="abc.gif">.

Does anyone know how to create Reports with Access and export them to HTML
with Image Tags?

Thanks a lot
Patrick
 

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