Sub myhtml()
Dim rst As DAO.Recordset
Dim i As Long
Dim j As Long
Dim fld As Field
Set rst = CurrentDb.OpenRecordset("Downloads")
'create/overwrite the original file
Open "C:\test.html" For Output As #1
'start with the html tag
Print #1, "<html>"
'body tag, you can insert whatever you want here
Print #1, "<body>"
With rst
.MoveFirst
'table tag
Print #1, "<table>"
'First row: table names
Print #1, "<TR>"
Print #1, "<TD>Record number</TD>" 'just to count the records
'print field names
For j = 0 To .Fields.Count - 1
Print #1, "<TD>" & .Fields(j).Name & "</TD>"
Next
'First row finished
Print #1, "</TR>"
'start looping through the recordset
Do Until .EOF
'evaluate each row of data
Print #1, "<TR>"
Print #1, "<TD>" & i + 1 & "</TD>" 'insert record counter
'find and output field values in current record
For Each fld In rst.Fields 'For j = 0 To .Fields.Count - 1
Print #1, "<TD>" & fld.Value & "</TD>"
Next
'finish row
Print #1, "</TR>"
i = i + 1 'record counter
'move to next record
.MoveNext
Loop
'close recordset
.Close
End With
Print #1, "</table>"
Set rst = Nothing
'end with the body
Print #1, "</body>"
'html end here
Print #1, "</html>"
'close new html file
Close #1
End Sub