Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

syntax help with VB Script

I have three conditions to show a region.

1. Show IF the recordset is empty
2. Show IF the recordset IS NOT empty AND the value of 'email' = 1

This is what I got so far:

for 1:  

<% If Qnrpg1.EOF And Qnrpg1.BOF Then %>

for 2:  

<% If (Not Qnrpg1.EOF Or Not Qnrpg1.BOF) AND (Qnrpg1.Fields.Item("email").Value = "1")) Then %>

The second one gives me the following syntax error:

Expected 'Then'

/bluedot/questionnaire/QnrPersonalInfo.asp, line 626

If (Qnrpg1.Fields.Item("email").Value = "1")) Then

-----

so two things:   First fix the syntax error, second put both conditions together in one.

I close the above with

 <% End If  %>
0
Aleks
Asked:
Aleks
1 Solution
 
Meir RivkinFull stack Software EngineerCommented:
<%If (Qnrpg1.EOF And Qnrpg1.BOF) Or ((Not Qnrpg1.EOF Or Not Qnrpg1.BOF) AND (Qnrpg1.Fields.Item("email").Value = "1")) Then %>

 <% End If  %>

Open in new window

0
 
AleksAuthor Commented:
:)
0
 
Scott Fell, EE MVEDeveloperCommented:
I think you will get an error for testing a value when the rs is empty and therefor, I use two lines.  I also convert the field to a string to make sure we are not mixing up alpha and numeric.
x="no"
If not Qnrpg1.EOF OR not Qnrpg1.BOF Then 
     if cstr(Qnrpg1.Fields.Item("email").Value) = "1"
         x="yes"
     end if
end if
response.write x

Open in new window

0

Featured Post

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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now