UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> If X<5, Print One Paragraph, Else Print Different Paragraph. Help Me With X?    
 
   
TinyGiant2010
post Mar 16 2017, 05:10 PM
Post#1



Posts: 158
Joined: 1-June 10



More succinctly: I need to show 2 paragraphs based upon the value of the [now list] field.
Paragraph one is "This is not a sheriff sale"
Paragraph two is "This is a sheriff sale. Validate everything"

I marked every sheriff sale record using the [now list] field; and did so by putting a default value of $1 in it.
For paragraph one to be shown, the [now list] value will be, in real life, greater than 100.
For paragraph two to be shown, the [now list] value will be equal to 1, but we can just say <5

Here is part of programming that retrieves the [now list field]
<%
Response.Buffer = True
Dim cn
Dim rs
Set cn = Server.CreateObject("ADODB.Connection")

cn.Open GetConnString()

Dim sSQL
sSQL = "SELECT subdiv, design, legal, exterior, asfla, " & _
"lotdim, idno2, idno, nr1, news, street, [now list], [seller assistance], icode, cars, " & _
"bsmt, heat, [living room dim], listed, realtorrem, [Orig List]," & _

"FROM [FREIS] " & _
"WHERE idno = " & Request("id")


Set rs = cn.Execute(sSQL)
%>

I received advise elsewhere

<% if(now_list < 5) { %>

<a href="link1.html">Link 1</a>
<a href="link2.html">Link 2</a>
<a href="link3.html">Link 3</a>

<% } else { %>

<p>Different HTML code</p>

<% } %>

and I modified it thusly, and it did not work.

<% if(now_list < 5) { %>

<p>This is a sheriff sale. Validate everything</p>

<% } else { %>

<p>This is not a sheriff sale</p>

<% } %>


It seems it is not evaluating the [now list] vs 5 properly and I don't know how to fix it. I've tried [] and (), but it isn't working.

Any clues would be welcomed.

--------------------
Self taught newbie just trying to remember that fields are in tables and controls are on forms.
Go to the top of the page
 
Doug Steele
post Mar 16 2017, 05:15 PM
Post#2


UtterAccess VIP
Posts: 21,497
Joined: 8-January 07
From: St. Catharines, ON (Canada)


Since [now list] is a field being returned in the recordset you opened, you need to refer to the recordset as well:

CODE
<% if(rs!now_list < 5) { %>

--------------------
Go to the top of the page
 
TinyGiant2010
post Mar 17 2017, 07:59 AM
Post#3



Posts: 158
Joined: 1-June 10



Hello Doug, thanks for trying to help.

I tried many variants, but none seemed to work. The one that worked "best" is this one; as the little _______^ indicator got all the way to the { in the top line; but got no further.

<%if 8 > (rs("[now list]")) { %>
<p>This is a Sheriff Sale. Validate all information yourself.</p>
<% } else { %>
<p>This is not a Sheriff Sale. </p<
<% } %>

I tried all sorts of different configurations utilizing the rs in the statement, various bracketing using all I could think of with () and {}; as well as rs, and rs! and =rs! and so forth.

I don't understand how the statement can be evaluated all the way to the "then" and then stop. I've already used an hour this morning "experimenting"

I'm wondering if this might work instead, but I am out of time to test: (cleaning out some <% info?)

<%if 8 > (rs("[now list]")) {
<p>This is a Sheriff Sale. Validate all information yourself.</p>
} else {
<p>This is not a Sheriff Sale. </p<
} %>

this returned this error on the page:
Microsoft VBScript compilation error '800a0408'

Invalid character

/res/details01f.asp, line 127

if 8 > (rs("[now list]")) {
---------------------


with the ^ pointing underneath the { on line one.

I am stumped.

Thanks again for trying.

--------------------
Self taught newbie just trying to remember that fields are in tables and controls are on forms.
Go to the top of the page
 
TinyGiant2010
post Mar 17 2017, 09:39 AM
Post#4



Posts: 158
Joined: 1-June 10



Posed question here as well. When I get a working answer, I will share here.

https://social.msdn.microsoft.com/Forums/en...ement?forum=web

--------------------
Self taught newbie just trying to remember that fields are in tables and controls are on forms.
Go to the top of the page
 
Doug Steele
post Mar 17 2017, 03:37 PM
Post#5


UtterAccess VIP
Posts: 21,497
Joined: 8-January 07
From: St. Catharines, ON (Canada)


Sorry: I'd missed the fact that there was a space in the field name. (Never a good idea!)

If you can't correct the field name, try

CODE
<% if(rs.Fields("now list") < 5) { %

--------------------
Go to the top of the page
 
TinyGiant2010
post Mar 17 2017, 04:41 PM
Post#6



Posts: 158
Joined: 1-June 10



Thanks Doug, I will try that in a moment. Before I do, I thought I'd share a tidbit from the Microsoft forum (after they smacked me around a little).

<% if (8>2) then %>
<p>This is the true response.</p>
<% else %>
<p>This is the false response. </p>
<% end if %>

When I change the < and > sign, the correct true or false response show up.
The method above shows the correct syntax I think.

Now I will need to substitute the (8>2) with the correct variables to evaluate.
I wanted to put my babysteps here above before I lost them!

I just tried this:
<% if (rs.Fields("now list")<5 then %>
<p>This is the true response, this is a Sheriff Sale.</p>
<% else %>
<p>This is the false response. </p>
<% end if %>

It didn't work, so I modified slightly with []

<% if (rs.Fields("[now list]")<5 then %>
<p>This is the true response, this is a Sheriff Sale.</p>
<% else %>
<p>This is the false response. </p>
<% end if %>

This does not work either.
now I will change (rs.Fields( to just (rs("now list") and see what happens (with no [] here)

<% if (rs("now list")<5 then %>

This does not work either. hmmm; trying different method of [] removal next; and added a ) outside of the 5:
<% if (rs.Fields("now list")<5) then %>

EURIKA!! This code above returns the true response. YEA!!!
Now to force a false response; I am simply flipping the < sign to >

<% if (rs.Fields("now list")>5) then %>
<p>This is the true response, this is a Sheriff Sale.</p>
<% else %>
<p>Write the regular REALTOR sale response. </p>
<% end if %>

This returned the false response.

So, testing true with condition "now list" <5 returns true response .... and
testing the false condition by changing the evaluation to "now list" >5 works.

This will be so handy!! Thanks for helping Doug, I really do appreciate it. I could not have solved without you! Thanks a million!

--------------------
Self taught newbie just trying to remember that fields are in tables and controls are on forms.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    16th December 2017 - 07:54 AM