Solved

syntax help with VB Script

Posted on 2013-06-24
3
351 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
Comment Utility
<%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
Comment Utility
:)
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
The viewer will learn how to count occurrences of each item in an array.
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…

762 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

15 Experts available now in Live!

Get 1:1 Help Now