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
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
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
that look like this:From this I need to produce individual HTM files - one per server -
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