Skip to main content
April 22, 2007
Answered

Show (a Region) IF recordset field = (value)

  • April 22, 2007
  • 5 replies
  • 778 views
Hi -- I am working on ASP Javascript, and need to show a region if a recordset's column in my Access database shows a particular value. How do I write this? Thanks.
This topic has been closed for replies.
Correct answer Creativ_Technologies
<% if (rs_SanFran.Fields.Item("OpenClose").value == "Open") { %>
Register now!
<% }else{ %>
Do something else
<% } %>

5 replies

Creativ_TechnologiesCorrect answer
Inspiring
April 23, 2007
<% if (rs_SanFran.Fields.Item("OpenClose").value == "Open") { %>
Register now!
<% }else{ %>
Do something else
<% } %>
April 23, 2007
Thanks, that was it! Such a relief! I appreciate your time.

Inspiring
April 23, 2007
You are forgetting the "Fields" method.

Change:
<% if (rs_SanFran.item("OpenClose").value == "Open") { %>
Register now!<% } %>

To:
<% if (rs_SanFran.Fields.Item("OpenClose").value == "Open") { %>
Register now!
<% } %>

April 23, 2007
Oh, that did it thanks! I should have caught that.

Question: If I wanted to modify that to an IF THEN ELSE statement, how would I change that?

Thanks.
Inspiring
April 22, 2007
Please provide the code block you are trying.
April 22, 2007
ok, here's the code block -- thanks for your help.



<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" class="dottedlines" scope="row"><p class="subheader">San Francisco </p></td>
</tr>
<% while ((Repeat1__numRows-- != 0) && (!rs_SanFran.EOF)) { %>
<tr>
<td valign="top" scope="row"> <p> <strong><%=(rs_SanFran.Fields.Item("LocationName").Value)%></strong> <%=(rs_SanFran.Fields.Item("LocationDescription").Value)%><br>
<%=(rs_SanFran.Fields.Item("LocationDaysTimes").Value)%>
<br>
<% if (rs_SanFran.item("OpenClose").value == "Open") { %>
Register now!<% } %>

Sorry, this program is filled.

<p><br>
</td>
</tr>
<%
Repeat1__index++;
rs_SanFran.MoveNext();
}
%>
</table>

Inspiring
April 22, 2007
sorry, that was in VB script.

try:

<% if (rs.fields.item("field").value == "value") { %>
something to show
<% } %>
April 22, 2007
Thanks for getting back so fast...I feel like I'm working blindly here, so your help is greatly appreciated.

I got another error:

Microsoft JScript runtime error '800a01b6'
Object doesn't support this property or method

It specifies the line containing the IF statement. What does this error mean, and how can I fix? Am I doing right by putting it exactly in the page where I want the text to appear?

Thanks.
Inspiring
April 22, 2007
<% if (rs.fields.item("field").value = "value") then %>
something to show
<% end if %>
April 22, 2007
I get this error:

Microsoft JScript compilation error '800a03ec'
Expected ';'

pointing me to the line that has <% end if %> on it.

I put the code right into the part of the page where I want the information to appear if the column of the recordset is a particular value.