instead of checking for nothing, check for something.
if len(rsProposals.Fields.Ite
else....
end if
But, no text means no color at all, why change color when there is no text?
Main Topics
Browse All Topics I have an asp page that displays info from an access DB. One of the fields in the database (rationale column) contains some text. I'm having trouble figuring out how to check if the rationale field (rsProposals.fields.item("
<td><div align="center"><font size="-1" face="Arial, Helvetica, sans-serif">
<% Response.Write (rsProposals.Fields.Item("
the rationale text/value shows up fine in my asp page.
The problem comes in when I try to check whether the rationale field contains anything, in order to change the color of the value displayed from the proposal column. This is how I do it:
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<%
if isNull(rsProposals.fields.
Response.Write "<font color=""#009A76""> "& (rsProposals.Fields.Item("
else
Response.Write "<font color=""#FF0000""> "& (rsProposals.Fields.Item("
end if
%>
</font></td>
(All code examples are in a repeat region)
What happens when I do this checking is that the value of the rationale field does not get displayed now. In the HTML table on the asp page, the proposal field comes before the rationale field - if this makes any difference.
Is there any reason why the rationale text/value would fail to show up if I used ISNULL to check it's value when displaying the contents of the proposal field. Same thing happens when I use ISEMPTY. Is there a way around this - or another way to check if a field is empty? Thanks!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
For now, I want to print out the value of proposal in a different color if the value of rationale is empty/null - or not. I eventually want to have the value of proposal displayed in form of a link which when clicked on would open a new window containing the value of rationale - i.e. if there's something in rationale, there's a link, - if there's nothing, no link...
You could also do something like this:
<%
strRaionale = Trim(rsProposals("Rational
strProposal = Trim(rsProposals("Proposal
if not isNull(strRaionale ) and strRaionale <> "" then
strFontColor = "#009A76"
else
strFontColor = "#FF0000"
end if
%>
<td>
<font size="-1" face="Arial, Helvetica, sans-serif">
<font color="<%=strFontColor%>">
</font>
</td>
=:o))
Bill_Harding:
I tried your approach as
if len(rsProposals.Fields.Ite
Response.Write "<font color=""#009A76""> "& (rsProposals.Fields.Item("
else
Response.Write "<font color=""#FF0000""> "& (rsProposals.Fields.Item("
end if
This changes the color of the value of proposal according to whether the Rationale field contains something,as desired, but the value for Rationale doesn't show up!...
When I take out the [if len(rsProposals.Fields.Ite
Response.Write "<font color=""#009A76""> "& (rsProposals.Fields.Item("
The value of Rationale shows up now. Here's what Rationale's ASP code looks like:
<td><div align="center"><font size="-1" face="Arial, Helvetica, sans-serif">
<%
Response.Write (rsProposals.Fields.Item("
Dxpert:
I tried your example, as outlined below:
<%
dim strRationale
strRationale = Trim(rsProposals("Rational
if not isNull(strRationale ) and strRationale <> "" then
Response.Write "<font color=""#009A76""> "& (rsProposals.Fields.Item("
else
Response.Write "<font color=""#FF0000""> "& (rsProposals.Fields.Item("
end if
%>
'strRationale = Trim((rsProposals.Fields.I
Result: - the value/txt of proposal shows up in different colors depending on whether the value for Rationale is empty/null - GOOD, but then again the value of Rationale REFUSES to show up! Here's the code for Rationale's display:
<td><div align="center"><font size="-1" face="Arial, Helvetica, sans-serif">
<% Response.Write (rsProposals.Fields.Item("
</font></div></td>
Do you guys know why the value for Rationale doesn't show up when we include logic to check whether or not it's empty - it seems to be doing this across the board regardless of whether we use Len, ISNULL or ISEMPTY!
I tried:
<%
dim strRationale
strRationale = Trim(rsProposals("Rational
Response.Write "<font color=""#FF0000""> "& (rsProposals.Fields.Item("
%>
and the value of Rationale still wouldn't show up - it is only when I commented out 'strRationale = Trim(rsProposals("Rational
I'm not sure what's going on here, and why the value for Rationale is absent with the inclusion of something as benign as
strRationale = Trim(rsProposals("Rational
Ok, I'll try this again... Like I said I have an access DB whole values I'm pulling up and displaying on main.asp. Two of the columns in the DB are the Proposals and Rationale columns. For now I'm trying to change the color of the value of PROPOSAL for each row in the repeat region, depending in whether the value of RATIONALE is null/empty - or not.
The way this info is being displayed on main.asp is on an HTML table with columns corresponding to the columns in the access DB. The code I've been providing, above, is that of the Proposal and Rationale columns. That said, I'm having problems with the value of the Rationale column not showing up when I try to use some logic to determine whether the value of Rationale is empty.
The code b4 using the logic looks like:
For Proposal column:
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<%
dim strRationale
Response.Write "<font color=""#FF0000""> "& (rsProposals.Fields.Item("
%>
</font></td>
For Rationale column:
<td><div align="center"><font size="-1" face="Arial, Helvetica, sans-serif">
<%
Response.Write (rsProposals.Fields.Item("
%>
</font></div></td>
In this setup, the value of the Rationale column shows up in main.asp
The code using the logic to check whether the Rationale column is empty/null looks like:
For Proposal column:
<td><font size="-1" face="Arial, Helvetica, sans-serif">
dim strRationale
strRationale = Trim(rsProposals("Rational
'strRationale = Trim((rsProposals.Fields.I
if not isNull(strRationale ) and strRationale <> "" then
Response.Write "<font color=""#009A76""> "& (rsProposals.Fields.Item("
else
Response.Write "<font color=""#FF0000""> "& (rsProposals.Fields.Item("
end if
%>
</font></td>
For Rationale column:
<td><div align="center"><font size="-1" face="Arial, Helvetica, sans-serif">
<%
Response.Write (rsProposals.Fields.Item("
%>
</font></div></td>
With the logic in, the value for the Rationale column fails to get displayed - is blank, which is where I'm stuck/don't understand...
Have I explained myself better/Does it make sense now? Thanks again for your suggestions
Ok, I've changed my approach a bit - made things simpler. What I'm doing now is I'm trying to display the value of Rationale for a given row result in form of a link that's independent of whether or not the Rationale field is empty. I'm using the value of the company field as the link text. Here's the code:
main.asp
<td><div align="center"><font size="-1" face="Arial, Helvetica, sans-serif">
<%
dim str_rationale
str_rationale = rsProposals("Rationale")
response.write "<A href = 'rationales2.asp?str_text=
Response.Write (rsProposals.Fields.Item("
Response.Write "</A>"
%>
</font></div></td>
rationales2.asp
dim passed_text
passed_text = request.querystring("str_t
if len(str_text) = 0 then
response.write " dang it, it still didn't work.."
else
response.write "The value passed from the previous link = " & str_text & "<BR>"
end if
What happens now is that the value of Rationale can be seen (on the browser status bar) when I hover over the link to it, but when I click on the link itself to view the full Rationale text in the new window (as per the code) there's nothing in "str_text" - I get "dang it, it still didn't work.." It's quite baffling! - see anything I'm doing wrong in passing/retrieving the variables? Thanks guys.
Business Accounts
Answer for Membership
by: DxpertPosted on 2003-06-10 at 12:18:59ID: 8693705
Actually, you should add the field value to a Variable since you are going to be using it multiple times:
e"))
e"))
Proposal") .Value) &" </font>"
strRaionale = Trim(rsProposals("Rational
Then you can do IsNull(strRaionale) - this will check for NULL values, also (strRaionale = "") - this will check for an empty string, also len(strRaionale) = 0 - this will check that the length is equal to Zero.
<%
strRaionale = Trim(rsProposals("Rational
%>
<td><font size="-1" face="Arial, Helvetica, sans-serif">
<%
if not isNull(strRaionale ) and strRaionale <> "" then
Response.Write "<font color=""#009A76""> "& (rsProposals.Fields.Item("
else
Response.Write "<font color=""#FF0000"">SOME OTHER VALUE</font>"
end if
%>
</font></td>
=:o))