Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 28th, 2005, 02:51 AM
SoC SoC is offline
Authorized User
 
Join Date: Jul 2004
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default Loop through records- stop if certain value met

Hi,

I have a little problem with a loop. I have a little script that will show a small flash movie if a record contains a certain value.

The problem with my code is that if there is more than one record that equals that value, more flash movies will be shown.

I only want one to show. Here is my dodgy code:

Code:
<%While not rsNews.eof
If rsNews.Fields.Item("dateAdded").Value = theDate then%>
<object>My Flash movie code here
            </object>
<%end if%>
<%
rsNews.movenext()
Wend%>
I haven't really used loops before, so if someone could please explain it would be great.

thanks

s

 
Old July 28th, 2005, 03:32 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hey s,

Try changing the loop to a Do...Loop structure and using the Exit Do statement...
Code:
<%
Do Until rsNews.eof
    If rsNews.Fields.Item("dateAdded").Value = theDate Then
        %>
        <object>My Flash movie code here</object>
        <%
        Exit Do
    End If
    rsNews.movenext()
Loop
%>
HTH,

Chris

 
Old July 28th, 2005, 08:22 PM
SoC SoC is offline
Authorized User
 
Join Date: Jul 2004
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, that's perfect. Thanks very much Chris






Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop button won't stop loop JDShaffer Visual Basic 2008 Essentials 3 May 23rd, 2008 03:22 PM
Loop through records on Continuous Form paulcbyrum Access 1 May 13th, 2008 06:28 AM
Mail Loop Will Randomly Stop Working jimmlegs VBScript 1 February 2nd, 2004 08:18 AM
Query and loop records... HELP! hcweb Classic ASP Basics 3 January 9th, 2004 04:50 PM
update records by the loop mateenmohd SQL Server 2000 2 July 16th, 2003 06:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.