Link to home
Start Free TrialLog in
Avatar of Aleks
AleksFlag for United States of America

asked on

Show region if recordset is empty or if its not empty and value = 1

I have a region that I need to show if a recordset is empty OR if the recordset is not empty AND the value of the field = 1

This is the code I currently have to show it if the value = 1  I just need to add code to show it where that is the case OR if the recordset is empty

<% If rs_qnrpages.Fields.Item("pg_02_addresses").Value = (1) Then 'script %>
MY REGION
<% End If  %> 

Open in new window


I need to add if 'rs_qnrpages' is empty OR the above then show that region.

I am using ASP classic
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

Unfortunately, VBScript does not have a "short-circuit" for the IF statement. So you will probably need to set a flag for each condition and use it to determine if you need to display your region. Try something like this:
<%
Dim ShowRegion
ShowRegion = False
If rs_qnrpages.RecordCount = 0 Then
   ShowRegion = True
ElseIf rs_qnrpages.Fields.Item("pg_02_addresses").Value = (1) Then 
   ShowRegion = True
End If
If ShowRegion Then %>
MY REGION
<% End If %>

Open in new window

Also, instead of using RecordCount, you could check if your recordset is at end of file (.EOF).
ASKER CERTIFIED SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Aleks

ASKER

This seems to have worked and its easier.