Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > ASP Forms
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms 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 October 3rd, 2003, 07:56 AM
Authorized User
 
Join Date: Jul 2003
Posts: 41
Thanks: 0
Thanked 1 Time in 1 Post
Default search tables - if EOF do this and go 2 next table

I have two fiscal years. I want to search one if something is found list it and if not tell the user nothing found....go on and search the next year.

the results should be something like

FY03
    Nothing found

FY04
    Silicon Graphics 800
    Microsoft 700

I know how to check if its eof...but how do I check if any records were found before eof?

 
Old October 4th, 2003, 02:56 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

I am not sure I understand your situation 100%. Are all records for both fiscal year in the same recordset (if they are present)?, like this:

FY03 Silicon Graphics 800
FY04 Silicon Graphics 800
FY04 Microsoft 700

while another search may result in this:

FY04 Silicon Graphics 800
FY04 Microsoft 700

If that's the case, you can simply look at the values in the recordset, and see if they match your criteria. For this to work, you'll need to add the fiscal year somewhere (as a column in your query for example) and you'll need to sort the results on this fiscal year:
Code:
Dim FY03Done
FY03Done = False
Do While Not MyRecordset.EOF
  If FY03Done = False Then
    ' Is the first record. See if 03 is found
    If MyRecordset("FY") = "2003" Then
      ' If 2003 is found, there is no need to display the message
    Else
      ' Recordset does not start with a record for FY 2003, 
      ' so display a message
      Response.Write("No records for FY 2003")
    End If
    FY03Done = True
  End If
  Response.Write("Recordset value " & MyRecordset("CompanyName"))
  MyRecordset.MoveNext()
Loop
This way, the first time the loop runs, you check whether the record is a record for 2003. If it is not, you can display a message. If it is, you can simply output its value.

Depending on your needs for this application, you may need to copy the line that writes out MyRecordset("CompanyName") to inside the loop, so its only outputted when appropriate.

You can expand this example, so it adds the FY above the results, but only when it changes from the previous record.

Does this help?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Query to Search for a value in a table Vendirella SQL Language 0 October 10th, 2007 12:47 AM
How do I search a database with 4 tables from VB 6 Szimmer9 VB How-To 6 March 23rd, 2006 10:56 AM
search table? bmurty Access VBA 1 September 21st, 2005 06:51 AM
Search on multi tables mani_he Pro PHP 4 November 23rd, 2004 09:07 PM
Relating 2 Tables be search for single field value bsimecek SQL Language 4 October 4th, 2004 09:24 AM





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