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

Problems with Null value in field

Status
Not open for further replies.

cactus1000

Programmer
Aug 31, 2001
149
US
I have an If Then statement that executes based on whether a particular field contains any data or not.

When I use this line:

If IsNull(Lastname2) then

It identifies records without Null values in this field and triggers the Else statement. However, it acts as if every record is without Null values in this field.

When I try:

If Lastname2=""

or:

If IsEmpty(Lastname2)

or even:

If Lastname2 = "" or IsEmpty(Lastname2) or IsNull(Lastname2)

I get the opposite effect - it fails to identify records that have entries in this field.

What am I doing wrong?

Here's the whole thing:



If IsNull(Lastname2) then

Do While Not objRS.EOF

Response.Write &quot;<tr><td><b><i><font color='#000066'>Name:</b></i></font></td><td>&quot; & objRS(&quot;Lastname&quot;) & &quot;, &quot; & objRS(&quot;Firstname&quot;) & &quot;</td></tr>&quot;
Response.Write &quot;<tr><td><b><i><font color='#000066'>Title:</b></i></font></td><td>&quot; & objRS(&quot;Title&quot;) & &quot;</td></tr>&quot;
Response.Write &quot;<tr><td><b><i><font color='#000066'>Department:</b></i></font></td><td>&quot; & objRS(&quot;Department&quot;) & &quot;</td></tr>&quot;
Response.Write &quot;<tr><td><b><i><font color='#000066'>Phone:</b></i></font></td><td>&quot; & objRS(&quot;Phone&quot;) & &quot;</td></tr>&quot;
Response.Write &quot;<tr><td><b><i><font color='#000066'>Fax:</b></i></font></td><td>&quot; & objRS(&quot;Fax&quot;) & &quot;</td></tr>&quot;
Response.Write &quot;<tr><td><b><i><font color='#000066'>Email:</b></i></font></td><td>&quot; & objRS(&quot;Email&quot;) & &quot;</td></tr>&quot;
Response.Write &quot;<tr><td><b><i><font color='#000066'>Office:</b></i></font></td><td>&quot; & objRS(&quot;Building&quot;) & &quot; &quot; & objrs(&quot;Office&quot;) & &quot;</td></tr>&quot;
Response.Write &quot;<td><hr><td><hr></td></tr>&quot;
objRS.MoveNext
Loop
objRS.Close
Set objRS = Nothing
objdc.Close
Set objdc = Nothing

Else
Do While Not objRS.EOF
Response.Write &quot;<tr><td><b><i><font color='#000066'>Namex:</b></i></font></td><td>&quot; & objRS(&quot;Lastname&quot;) & &quot; &quot; & objrs(&quot;Lastname2&quot;)&&quot;, &quot; & objRS(&quot;Firstname&quot;) & &quot;</td></tr>&quot;

Response.Write &quot;<tr><td><b><i><font color='#000066'>Title:</b></i></font></td><td>&quot; & objRS(&quot;Title&quot;) & &quot;</td></tr>&quot;
Response.Write &quot;<tr><td><b><i><font color='#000066'>Department:</b></i></font></td><td>&quot; & objRS(&quot;Department&quot;) & &quot;</td></tr>&quot;
Response.Write &quot;<tr><td><b><i><font color='#000066'>Phone:</b></i></font></td><td>&quot; & objRS(&quot;Phone&quot;) & &quot;</td></tr>&quot;
Response.Write &quot;<tr><td><b><i><font color='#000066'>Fax:</b></i></font></td><td>&quot; & objRS(&quot;Fax&quot;) & &quot;</td></tr>&quot;
Response.Write &quot;<tr><td><b><i><font color='#000066'>Email:</b></i></font></td><td>&quot; & objRS(&quot;Email&quot;) & &quot;</td></tr>&quot;
Response.Write &quot;<tr><td><b><i><font color='#000066'>Office:</b></i></font></td><td>&quot; & objRS(&quot;Building&quot;) & &quot; &quot; & objrs(&quot;Office&quot;) & &quot;</td></tr>&quot;
Response.Write &quot;<td><hr><td><hr></td></tr>&quot;
objRS.MoveNext
Loop
objRS.Close
Set objRS = Nothing
objdc.Close
Set objdc = Nothing

End If
%>

 
Nevermind - I got it! (bad syntax)!

If isNull(objrs(&quot;Lastname2&quot;)) or isEmpty(objrs(&quot;Lastname2&quot;)) or objRS(&quot;Lastname2&quot;) = &quot;&quot; Then
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top