Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop through recordset

Status
Not open for further replies.

markdt

Technical User
Feb 15, 2006
63
GB
Hi people,

I have a recordset displayed as a table which basically holds all my customer concerns. What im trying to do is have some sort of field indicator which will remind me what state the concern is in. I wanted to have colour indicators depending on if a field is empty or not.

this is my code so far

Do While Not rstDBEdit.EOF
if rstDBEdit.Fields("tblconcern.areaid").Value="" then
dbColour="#FF0000"
end if
%>
<tr>
<td><%= rstDBEdit.Fields("concernid").Value %></td>
<td><%= rstDBEdit.Fields("CustomerName").Value %></td>
<td><%= rstDBEdit.Fields("Site").Value %></td>
<td><%= rstDBEdit.Fields("ConcernDetails").Value %></td>
<td><%= rstDBEdit.Fields("ProductDescription").Value %></td>
<td><%= rstDBEdit.Fields("ConDate").Value %></td>
<td><a href=" rstDBEdit.Fields("concernid").Value %>">View</a></td>
<td bgcolor=<%dbColour%>></td>
</tr>
<%
rstDBEdit.MoveNext
Loop

The last row of the table called state i want to display a colour. Any help would be greatly appreciated.
 
Still not working my code now is:

<%
Do While Not rstDBEdit.EOF
if rstDBEdit.Fields("tblConcern.AreaID").Value="" then
dbColour="#FF0000"
end if

if rstDBEdit.Fields("ShortPrev").Value="" then
dbColour="#FF6600"
end if
%>
<tr>
<td><%= rstDBEdit.Fields("concernid").Value %></td>
<td><%= rstDBEdit.Fields("CustomerName").Value %></td>
<td><%= rstDBEdit.Fields("Site").Value %></td>
<td><%= rstDBEdit.Fields("ConcernDetails").Value %></td>
<td><%= rstDBEdit.Fields("ProductDescription").Value %></td>
<td><%= rstDBEdit.Fields("ConDate").Value %></td>
<td><a href=" rstDBEdit.Fields("concernid").Value %>">View</a></td>
<td style="background-color:<%=dbColour%>">&nbsp;</td>
</tr>
<%
rstDBEdit.MoveNext
Loop
%>

Its setting all the indicators to orange now despite what value is held in either of the fields areaid or shortprev.
 
after this line:

rstDBEdit.MoveNext

do this

dbColour="#FFFFFF"

-DNG

 
Excellent guys,

Works great, thanks alot.

 
Got another one for ya,

Checking these fields for isNull works great, but when the record is updated to contain something and then updated again to contain nothing e.g "" it thinks there is something in the field.

if isNull(rstDBEdit("tblConcern.AreaID")) then
dbColour="#FF0000"
else
if isNull(rstDBEdit("ShortPrev")) then
dbColour="#FF6600"
end if
end if

When i update this field to contain text and then update again it runs code like

strSQL = "UPDATE tblConcern SET " _
& ", ShortPrev = '" & CStr(Replace(Request.Form("sprev"), "'", "''")) & "' " _

Any ideas

 
do this:

Code:
if isNull(rstDBEdit("tblConcern.AreaID")) OR rstDBEdit("tblConcern.AreaID")="" then
dbColour="#FF0000"
else
if isNull(rstDBEdit("ShortPrev")) OR rstDBEdit("ShortPrev")= "" then
dbColour="#FF6600"
end if
end if

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top