cactus1000
Programmer
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 "<tr><td><b><i><font color='#000066'>Name:</b></i></font></td><td>" & objRS("Lastname"
& ", " & objRS("Firstname"
& "</td></tr>"
Response.Write "<tr><td><b><i><font color='#000066'>Title:</b></i></font></td><td>" & objRS("Title"
& "</td></tr>"
Response.Write "<tr><td><b><i><font color='#000066'>Department:</b></i></font></td><td>" & objRS("Department"
& "</td></tr>"
Response.Write "<tr><td><b><i><font color='#000066'>Phone:</b></i></font></td><td>" & objRS("Phone"
& "</td></tr>"
Response.Write "<tr><td><b><i><font color='#000066'>Fax:</b></i></font></td><td>" & objRS("Fax"
& "</td></tr>"
Response.Write "<tr><td><b><i><font color='#000066'>Email:</b></i></font></td><td>" & objRS("Email"
& "</td></tr>"
Response.Write "<tr><td><b><i><font color='#000066'>Office:</b></i></font></td><td>" & objRS("Building"
& " " & objrs("Office"
& "</td></tr>"
Response.Write "<td><hr><td><hr></td></tr>"
objRS.MoveNext
Loop
objRS.Close
Set objRS = Nothing
objdc.Close
Set objdc = Nothing
Else
Do While Not objRS.EOF
Response.Write "<tr><td><b><i><font color='#000066'>Namex:</b></i></font></td><td>" & objRS("Lastname"
& " " & objrs("Lastname2"
&", " & objRS("Firstname"
& "</td></tr>"
Response.Write "<tr><td><b><i><font color='#000066'>Title:</b></i></font></td><td>" & objRS("Title"
& "</td></tr>"
Response.Write "<tr><td><b><i><font color='#000066'>Department:</b></i></font></td><td>" & objRS("Department"
& "</td></tr>"
Response.Write "<tr><td><b><i><font color='#000066'>Phone:</b></i></font></td><td>" & objRS("Phone"
& "</td></tr>"
Response.Write "<tr><td><b><i><font color='#000066'>Fax:</b></i></font></td><td>" & objRS("Fax"
& "</td></tr>"
Response.Write "<tr><td><b><i><font color='#000066'>Email:</b></i></font></td><td>" & objRS("Email"
& "</td></tr>"
Response.Write "<tr><td><b><i><font color='#000066'>Office:</b></i></font></td><td>" & objRS("Building"
& " " & objrs("Office"
& "</td></tr>"
Response.Write "<td><hr><td><hr></td></tr>"
objRS.MoveNext
Loop
objRS.Close
Set objRS = Nothing
objdc.Close
Set objdc = Nothing
End If
%>
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 "<tr><td><b><i><font color='#000066'>Name:</b></i></font></td><td>" & objRS("Lastname"
Response.Write "<tr><td><b><i><font color='#000066'>Title:</b></i></font></td><td>" & objRS("Title"
Response.Write "<tr><td><b><i><font color='#000066'>Department:</b></i></font></td><td>" & objRS("Department"
Response.Write "<tr><td><b><i><font color='#000066'>Phone:</b></i></font></td><td>" & objRS("Phone"
Response.Write "<tr><td><b><i><font color='#000066'>Fax:</b></i></font></td><td>" & objRS("Fax"
Response.Write "<tr><td><b><i><font color='#000066'>Email:</b></i></font></td><td>" & objRS("Email"
Response.Write "<tr><td><b><i><font color='#000066'>Office:</b></i></font></td><td>" & objRS("Building"
Response.Write "<td><hr><td><hr></td></tr>"
objRS.MoveNext
Loop
objRS.Close
Set objRS = Nothing
objdc.Close
Set objdc = Nothing
Else
Do While Not objRS.EOF
Response.Write "<tr><td><b><i><font color='#000066'>Namex:</b></i></font></td><td>" & objRS("Lastname"
Response.Write "<tr><td><b><i><font color='#000066'>Title:</b></i></font></td><td>" & objRS("Title"
Response.Write "<tr><td><b><i><font color='#000066'>Department:</b></i></font></td><td>" & objRS("Department"
Response.Write "<tr><td><b><i><font color='#000066'>Phone:</b></i></font></td><td>" & objRS("Phone"
Response.Write "<tr><td><b><i><font color='#000066'>Fax:</b></i></font></td><td>" & objRS("Fax"
Response.Write "<tr><td><b><i><font color='#000066'>Email:</b></i></font></td><td>" & objRS("Email"
Response.Write "<tr><td><b><i><font color='#000066'>Office:</b></i></font></td><td>" & objRS("Building"
Response.Write "<td><hr><td><hr></td></tr>"
objRS.MoveNext
Loop
objRS.Close
Set objRS = Nothing
objdc.Close
Set objdc = Nothing
End If
%>