I'm generating a report from a db, want a certain section of a table to be displayed only if there is data in a particular recordset field. The following code is intended to produce table rows only if a recordset field "Echo_Rpt_Comments" is not null. Execution of the code produced the "Comments:" headline, but the "Echo_Rpt_Comments" recordset data was not displayed.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Code:
<%
If Not IsNull(RcdsEcho("Echo_Rpt_Comments")) Then
%>
<tr>
<td width="10%"> </td>
<td width="20%"> </td>
<td width="70%"> </td>
</tr>
<tr>
<td bgcolor="Silver" colspan="2" width="30%">
<font face="Arial"><b>Comments:</b></font>
</td>
<td width="70%"> </td>
</tr>
<tr>
<td width="10%"> </td>
<td colspan="2" width="90%">
<font face="Arial"><%=RcdsEcho("Echo_Rpt_Comments")%></font>
</td>
</tr>
<%
End If
%>
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
I tested by adding another "If Not IsNull" statement for the "Echo_Rpt_Comments" field immediately following the preceding code. The result indicated that the value of the recordset field had changed to null. Why?
My successful workaround is to use a variable to hold the contents of the recordset field, and use the variable instead of the recordset field. The following code works as expected.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Code:
<%
Dim Echo_Comments
Echo_Comments = RcdsEcho("Echo_Rpt_Comments")
If Not IsNull(Echo_Comments) Then
%>
<tr>
<td width="10%"> </td>
<td width="20%"> </td>
<td width="70%"> </td>
</tr>
<tr>
<td bgcolor="Silver" colspan="2" width="30%">
<font face="Arial"><b>Comments:</b></font>
</td>
<td width="70%"> </td>
</tr>
<tr>
<td width="10%"> </td>
<td colspan="2" width="90%">
<font face="Arial"><%=Echo_Comments%></font>
</td>
</tr>
<%
End If
%>
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
This problem (and workaround solution) was observerd on 2 different web servers (TEST and PROD), each running WinNT4 (SP6a), IIS4. The db is Access97, web servers use ODBC driver (DSN) to hit it; MDAC v2.5 SP1 is installed on the boxes, as spec'd by the db vendor. Servers have both Jet v3.51 SP3 and Jet v4.0 SP6, but since I'm using ODBC to hit the db this is probably irrelevant.