Wrox Programmer Forums
|
Access ASP Using ASP with Microsoft Access databases. For Access questions not specific to ASP, please use the Access forum. For more ASP forums, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 9th, 2005, 01:03 AM
Registered User
 
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Empty Fields

Ok this is starting to bug me.
What I'm trying to do is display a list on records from the Database.
If a field is empty then I should display an image.
Here is the code.....


If rslist.fields("tablename")="" then <<<<<<problem is here
Response.Write "<table border=0 cellpadding=0 cellspacing=0
style=border-collapse: collapse width=100% bordercolor=#FF0000>" & vbcrlf & _
"<tr>" & vbcrlf & _
"<td>" & vbcrlf & _
"<p class=8><img border=0 src=images/emptyfield.gif width=146 height=10></td>" & vbcrlf & _
"</tr>" & vbcrlf & _
"</table>"

Else

Response.Write "<table border=0 cellpadding=0 cellspacing=0 style=border-collapse: collapse width=100% bordercolor=#FF0000>" & vbcrlf & _
"<tr>" & vbcrlf & _
"<td>" & vbcrlf & _
"<p class=8>" & rslist("tablename") & "</td>" & vbcrlf & _
"</tr>" & vbcrlf & _
"</table>"

End IF


I have tried using...

If rslist.fields("tablename")<> 0 then

but it only works with numbers
 
Old January 9th, 2005, 05:35 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

This is probably due to the fact that the field is not an empty string, but null. Either append an empty string to the field's value before you compare, or check the Length of the field's value:

If rslist.Fields("tablename").Value & "" = "" Then

This chnges any null value into an empty string ("") so you can successfully compare it with another empty string.

Alternatively, use this:

If Len(rslist.Fields("tablename").Value) = 0 Then

Both Null and an empty string have a length of 0.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 10th, 2005, 11:10 AM
Registered User
 
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ever ask a question because your so wired up then someone gives you the answer and you thinking "%#!@!?*....I somehow knew that"

Thank You very much
 
Old January 10th, 2005, 04:40 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yeah, that sounds familiar.... ;)

Glad I could help.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to count all empty fields in Biztalk biztalkuser Biztalk 0 January 4th, 2006 07:37 AM
AJAX and Empty Fields rvanandel Javascript How-To 1 December 29th, 2005 05:16 PM
How to check for empty fields in a form. crmpicco Javascript How-To 7 February 15th, 2005 10:38 AM
empty fields not hidden anymore (php/mySQL) jasmin Beginning PHP 1 January 17th, 2005 12:42 PM
Subreport for CR9 giving empty fields in reports yblee Crystal Reports 0 August 18th, 2004 10:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.