Response.Write

M

Mangler

Here is an easy one for the pros, yet hard for me (newbie).

If my recordset is empty I want to write "Not Complete" and if there is
a value, I want to write the value. Can someone tell me what I am
doing wrong?

<%
If IsEmpty(rsa.Fields.Item("reclaima")) Then
Response.Write("Not Complete")
Else
Response.Write(rsa.Fields.Item("reclaima"))
End If
%>

Also tried....

<%
If rsa.Fields.Item("reclaima") = "" Then
Response.Write("Not Complete")
Else
Response.Write(rsa.Fields.Item("reclaima"))
End If
%>
 
R

Ray Costanzo [MVP]

Try:

If rsa.EOF Then
REsponse.Write "Not complete"
Else
Response.Write rsa.Fields.Item("reclaima").Value
End If

Ray at work
 
E

Evertjan.

Mangler wrote on 24 okt 2006 in microsoft.public.inetserver.asp.general:
Here is an easy one for the pros, yet hard for me (newbie).

If my recordset is empty I want to write "Not Complete" and if there is
a value, I want to write the value. Can someone tell me what I am
doing wrong?

<%
If IsEmpty(rsa.Fields.Item("reclaima")) Then
Response.Write("Not Complete")
Else
Response.Write(rsa.Fields.Item("reclaima"))
End If
%>

Also tried....

<%
If rsa.Fields.Item("reclaima") = "" Then
Response.Write("Not Complete")
Else
Response.Write(rsa.Fields.Item("reclaima"))
End If
%>

I surmize the value is null, see below.

This depends on the database settings for that field.

VBS specs say:

IsEmpty returns True if the variable is uninitialized, or is explicitly set
to Empty; otherwise, it returns False. False is always returned if
expression contains more than one variable.

The following example uses the IsEmpty function to determine whether a
variable has been initialized:

Copy Code
Dim MyVar, MyCheck
MyCheck = IsEmpty(MyVar) ' Returns True.
MyVar = Null ' Assign Null.
MyCheck = IsEmpty(MyVar) ' Returns False.
MyVar = Empty ' Assign Empty.
MyCheck = IsEmpty(MyVar) ' Returns True.
 
R

Ray Costanzo [MVP]

After seeing Evertjan.'s interpretation of your post, I'm thinking you may
mean you're wondering if the data in your recordset is empty, not the
recordset itself. In that case,

Dim s
s = rsa.Fields.Item("reclaima").Value & ""

If s = "" Then
Response.Write "Not Complete"
Else
Response.Write s
End If

''Note that a null value and a value of ""
''will both give you the same output of "Not Complete"

Ray at work
 
F

Firas S Assaad

I know everything is working with you now.
but just for the records for the future,
if you encountered this error again, but those ways arent working
anymore, then try looking for the length of the data in the field
example

<%
If len(rsa.Fields.Item("reclaima")) = "0" Then
Response.Write("Not Complete")
Else
Response.Write(rsa.Fields.Item("reclaima"))
End If
%>


Hope this comes in handy sometimes


Best Regards
Firas S Assaad
 
R

Ray Costanzo [MVP]

I believe this will cause an error if the value is null. Also, Len returns
an integer, not a string, so you'd want to compare it to 0 without the
quotes.

Ray at work
 
G

gabba

If my recordset is empty I want to write "Not Complete" and if there is
a value, I want to write the value. Can someone tell me what I am
doing wrong?

<%
If IsEmpty(rsa.Fields.Item("reclaima")) Then
Response.Write("Not Complete")
Else
Response.Write(rsa.Fields.Item("reclaima"))
End If
%>

Try this....

If Trim(rsa.Fields.Item("reclaima"))="" or
IsNull(rsa.Fields.Item("reclaima")) Then
Response.Write("Not Complete")
Else
Response.Write(rsa.Fields.Item("reclaima"))
End If

This is right if you consider as "empty": blank text, white spaces, or a
null value.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top