Outputting data to HTML - Please help!

P

PerdueKaren

I have a table that lists servers with errors or no errors. If a
server has more than one error, it is listed more than once. Like
this:

Svr1 error1
Svr2 error1
Svr2 error2
Svr2 error3
Svr3 no error

From this I need to produce individual HTM files - one per server -
that look like this:


Svr2

Reported error(s): error1
Error2
Error3
(svr2.htm)


My VBA:

StrName2 = rs!Server
Do While Not rs.EOF
strFile = FreeFile
strName1 = rs!Server
strError1 = rs!errorind
colNames.Add (strName1)
colErrors.Add (strError1)

Open strName1 & ".html" For Output As strFile
Print #strFile, "<html>"
Print #strFile, "<title>"
Print # strFile, strName1
Print # strFile, "</title>"
Print # strFile, "<head>"

A bunch of Ifs that write different things to the files based on what
the errorInd field equals - this all works fine, and then...

Print # strFile, "<br>"
Print # strFile, "<h2><font face=arial font color=#cd0000>" &
"Server " & strName1 & " reported the following event log errors" &
"</h2>"
Print # strFile, "<br>"
Print # strFile, "</head>"
Print # strFile, "<body>"

Do While strName2= rs!Server
Print # strFile, "<h3><font face=arial font color=#cd0000>"
& rs!EventID & "</h3>"
rs.MoveNext
Loop

Print #strFile, "</body> </html>"
Close strFile
Loop

The bottom section - from the Do While... to the last Loop - seems
to be giving me the problems. I've tried different things with
different results:

Code 1:
Do While strName2 = strName1
Print #strFile, "<h3><font face=arial font color=#cd0000>" & rs!EventID
& "</h3>"
rs.MoveNext
If Not rs.EOF Then
StrName2 = rs!Server
Else
StrName2 = 0
rs.MovePrevious
End If
Loop
Print #strFile, "</body> </html>"
Close strFile
rs.MoveNext
Loop

Code 1 gives me spotty output - after a server with multiple errors,
the next server gets skipped.

Code 2:
Do While strName2 = rs!Server
Print #strFile, "<h3><font face=arial font color=#cd0000>" & rs!EventID
& "</h3>"
rs.MoveNext
Loop
Print #strFile, "</body> </html>"
Close strFile
rs.MovePrevious
strName2 = strName1
Loop

Code 2 goes to the first server with multiple errors and sticks in an
endless loop.

Code 3:
Do While strName2 = rs!Server
Print #strFile, "<h3><font face=arial font color=#cd0000>" & rs!EventID
& "</h3>"
rs.MoveNext
Loop
Print #strFile, "</body> </html>"
Close strFile
rs.MovePrevious
rs.moveprevious
Loop

Code 3 gives me all servers then starts back with the first one in the
list and freezes. I'm thinking this is the closest to correct, but I
can't figure out how to make it exit after the last one!


I am really new at all this and am trying to figure it out - but I am
banging my head into a wall and I just can't take the pain anymore!
Thanks in advance for any help anyone can offer.

Karen
 
P

PerdueKaren

Changes:


Do While Not rs.EOF
strFile = FreeFile
strName1 = rs!Server
strName2 = strName1
strError1 = rs!errorind
colNames.Add (strName1)
colErrors.Add (strError1)


The code that writes the pages and all goes in here

Do While strName2= strName1
Print # strFile, "<h3><font face=arial font color=#cd0000>" &
rs!EventID & "</h3>"
rs.MoveNext
strName1 = rs!server
Loop

Print #strFile, "</body> </html>"
Close strFile
Loop
 
G

Guest

Changes:


Do While Not rs.EOF
strFile = FreeFile
strName1 = rs!Server
strName2 = strName1
strError1 = rs!errorind
colNames.Add (strName1)
colErrors.Add (strError1)


The code that writes the pages and all goes in here

Do While strName2= strName1
Print # strFile, "<h3><font face=arial font color=#cd0000>" &
rs!EventID & "</h3>"
rs.MoveNext
strName1 = rs!server
Loop

Print #strFile, "</body> </html>"
Close strFile
Loop


Did it work???
 
P

PerdueKaren

Nope. Now I get two entries for some servers and one for others. I've
been messing with moving the code that writes it to the collections -
this is what makes the page with the server names and links - to
different parts in the code. I can't figure this out!
 
G

Guest

I believe that it has something to do with the recordsource and the way it
reads it. Could you send me exactly what your code reads?
 
G

Guest

I think it has something to do with the way it access the rs. Could you
send me exactly what your code reads?
 
G

Guest

I have a different solution to your problem. While coding would be alot more
fun and admirable, make a report and export it into html with the
DoCmd.OutputTo command. Or you could make an actual webpage in Access using
the wizard.
 

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