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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to hide HTML output when recordset field value is null? 2

Status
Not open for further replies.

PSchubert

Technical User
Jun 6, 2006
50
0
0
AU
Hi all,

I know from prior posts that you people know just what to say to help a brother out, so here goes:

What I want to do is just what the subject says, and here's what I've got that doesn't work:

Code:
<%
    [COLOR=green]'...[i]all this code in green works great[/i]

blah blah blah blah

    Response.Write("<TABLE Align='left' BORDER='0' CELLPADDING='20' CELLSPACING='2'><TBODY><TR><TD style='vertical-align:top'><FONT FACE=""ARIAL"" SIZE=""2"">" & rs("MyFieldName") & "<br>" & rs("MyFieldName2")) [/color]

[COLOR=red]If Not rs.EOF Or Not rs.BOF Then
		If Not IsNull rs("nfldFDimHeight") Then
			Response.Write("<br> &#160;&#160;framed " & rs("nfldFDimHeight") & " x " & rs("nfldFDimWidth") & " x " & rs("nfldFDimDepth") & " cm")
		End If
	End If[/color]

[COLOR=green]	Response.Write("<br> &#160;&#160;...more stuff here...</font></TD>")[/color]
%>

The problem is with the code in red. What I want is, if the field "nfldFDimHeight" is null, then don't display anything until the next Response.Write.

Thanks for your help!
 
You should report what error you get. Try the line below:
Code:
If Not IsNull(rs("nfldFDimHeight")) Then
 
If the above solution does not work, then also try this one:

Code:
If Not (rs.BOF and rs.EOF) Then        
     If Not IsNull(rs("nfldFDimHeight")) Then            
         Response.Write
     End If    
End If
 
See? That, right there, is why I post my questions here.

"Thank you," & (guitarzan) & (AzizKamal) & ", very much!"

Here is the final result, for anyone interested:

Code:
If Not (rs.EOF Or Not rs.BOF) Then
	If (rs("nfldFDimHeight") > "0") Then
		Response.Write("<br> &#160;&#160;" & rs("nfldFDimHeight") & " x " & rs("nfldFDimWidth") & " x " & rs("nfldFDimDepth") & " cm framed")
	End If
End If

I changed my table to record a zero instead of a null, but the extra parentheses work in either case. Actually, if it doesn't work without them, then I guess they're not really extra, are they? :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top