• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 350
  • Last Modified:

Check for Null in Memo Field Wierdness

I am trying to test for a null value in a memo field, and if it is null not print two lines on the web page, but if it is not null print them.

Here is the wierd behavior. On line 40 I have the following

<b>Eligibility:</b></br>
<%=objRS("Eligibility")%></br></br>

This will print the Line Eligibility, followed by the text in the field Eligibility in the table.

But if I include the following code above line 40

Dim strElig
If Len(Trim(objRS("Eligibility"))) = 0 Then
  strElig = "  "
Else
  strElig = objRS("Eligibility")
End If

which just tests for Eligibility being blank or not (I have also tried IsNull(objRs("Eligibility"), then the text for Eligibility does not print on the line below the word Eligibilty. IT IS AS IF CHECKING FOR NULL PREVENTS A NON NULL VALUE TO PRINT.

Any thought, as this is starting to drive me insane.
0
estackpo
Asked:
estackpo
  • 6
  • 4
  • 2
  • +2
1 Solution
 
jitgangulyCommented:
Try putting a &nbsp;

Dim strElig
If Len(Trim(objRS("Eligibility"))) = 0 Then
  strElig = "&nbsp;"
Else
  strElig = objRS("Eligibility")
End If
0
 
estackpoAuthor Commented:
No that didnt help

This code just prints the heading Eligibility, but not the value from the field.

<%If isNull(objRS("Eligibility")) = False Then%>
  <b>Eligibility:</b></br>
   <%=objRS("Eligibility")%></br></br>
<%End If%>

But this code prints the heading and the value from the field.

<b>Eligibility:</b></br>
<%=objRS("Eligibility")%></br></br>

It is as if  checking for null causes the value to not print.
0
 
cb1393Commented:
Do you have a "On Error Resume Next"? If so, commenting that out may give you an error and some additional insight into the problem.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
estackpoAuthor Commented:
No I dont have that included and I am not getting any errors
0
 
Vinod_VijayanVinCommented:
try

<%If  trim(objRS("Eligibility")) <> ""  Then%>
  <b>Eligibility:</b></br>
   <%=objRS("Eligibility")%>  
<%End If%>
 </br></br>



0
 
cb1393Commented:
If that doesn't work, you can at least see what you should be testing for:

<%
TestVar = objRS("Eligibility")
Response.Write VarType(TestVar)
%>

Possible values:

0      Empty (uninitialized)      
1      Null (no valid data)
2      Integer
3      Long integer
4      Single-precision floating-point number
5      Double-precision floating-point number
6      Currency
7      Date
8      String
9      Automation object
10      Error
11      Boolean
12      Variant (used only with arrays of Variants)
13      A data-access object
17      Byte
8192      Array
0
 
estackpoAuthor Commented:
No that didnt work and  neither does

<%If "*" &  trim(objRS("Eligibility")) & "*" <> "**"  Then%>
  <b>Eligibility:</b></br>
   <%=objRS("Eligibility")%>  
<%End If%>
 </br></br>

Seems like any code that test anything about objRS("Eliginility") prevents it from being printed if it is not null., because all the above code correctly prints the heading, just not the field value.
0
 
Vinod_VijayanVinCommented:
just write plain

  <b>Eligibility:</b></br>
   <%=objRS("Eligibility")%>  

and run the code and see if any value is printed for all conditions
if any value is printed for any condition then the code given should work
 
0
 
danataylorCommented:
Try this:

Dim strElig
If " " & objRS("Eligibility") = " " Then
  strElig = "  "
Else
  strElig = objRS("Eligibility")
End If
0
 
estackpoAuthor Commented:
cb1393

Dim strElig 'To test to see if Eligibility is to be printed
strElig = objRS("Eligibility")
response.write varType(strElig)

Gives a 1 on records that have no value in the field (Null) and 8 if it does have a value (string)

However if I put that code in the page then

<b>Eligibility:</b></br>
<%=objRS("Eligibility")%></br></br>

only prints the Eligibility title and not the value. If I rem out the response.write varType(strElig) I get the same result, but if I also rem out strElig = objRS("Eligibility") then the value for the field is printed correctly.

***********

danataylor

That gave me the same results.


*************
Vinod_VijayanVin

As mentioned somewhere above the code...

<b>Eligibility:</b></br>
<%=objRS("Eligibility")%>  

works fine for both blank and non blank values unless I somewhere above reference the eligibility field


And here is the final wierdness, which seems kind of consistent

<b>Eligibility:</b></br>
<%=objRS("Eligibility")%></br></br>

<b>Eligibility2:</b></br>
 <%=objRS("Eligibility")%></br></br>

will print

Eligibilty:
"text for eligibility field"

Eligibilty2:
BUT NOT PRINT TEXT FOR ELIGIBILITY FIELD THE SECOND TIME!!!
0
 
cb1393Commented:
Okay, one more from me:

<%
strElig = objRS("Eligibility")
If Not IsNull(strElig) Then
   %>
   <b>Eligibility:</b></br>
   <%=strElig%></br></br>
   <%
End If
%>
0
 
estackpoAuthor Commented:
cb1393

Didnt work. As soon as I try to read the value of objRS("Eligibility") it acts as if it if going to the end of the field and further reference to it finds the "pointer" at the end of the field and will not print anything. (see my example at the end of my last comment)
0
 
estackpoAuthor Commented:
cb 1393

That worked! Who would have thought that would have been necessary! And only on memo fields it seems. Thanks all for your assistance.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now