Solved

syntax help with VB Script

Posted on 2013-06-24
3
361 Views
Last Modified: 2013-06-24
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
Comment
Question by:amucinobluedot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39271442
<%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
 

Author Closing Comment

by:amucinobluedot
ID: 39271470
:)
0
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 39271499
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question