Solved

syntax help with VB Script

Posted on 2013-06-24
3
353 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
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 52

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
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.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

914 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now