SQL Search with no matching results 
Author Message
 SQL Search with no matching results

Hi all,
I'm wondering if there is a way to trap an SQL search which has no
matching results. The way I have it setup right now if there is no
matching results my recordset shows no records. I want to inform the
user that there was no matching results and then reset my recordset
back. However, I haven't found a way in SQL to know when my results
return zero records.  Here is my simple SQL search code:

form1!Data1.RecordSource = "Select * from DR where CourseID = '" &
SearchItem & "' "
form1!Data1.Refresh  'Updates the recordsource with JUST records which
match SQL search

This SQL statement works fine when there are records matching my search.

Regards,
Tim Hirtle



Thu, 14 Dec 2000 03:00:00 GMT  
 SQL Search with no matching results

check the .recordcount property of the resulting recordset object. This
will indicate a Zero if your query didn't find any matching records. You
can also check BOF and EOF if the recordcount property isn't supported by
your database (some RDO types).



Quote:
> Hi all,
> I'm wondering if there is a way to trap an SQL search which has no
> matching results. The way I have it setup right now if there is no
> matching results my recordset shows no records. I want to inform the
> user that there was no matching results and then reset my recordset
> back. However, I haven't found a way in SQL to know when my results
> return zero records.  Here is my simple SQL search code:

> form1!Data1.RecordSource = "Select * from DR where CourseID = '" &
> SearchItem & "' "
> form1!Data1.Refresh  'Updates the recordsource with JUST records which
> match SQL search

> This SQL statement works fine when there are records matching my search.

> Regards,
> Tim Hirtle



Fri, 15 Dec 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. editing SQL Search results

2. searching items and pattern matching

3. searching listview for partial match with text

4. searching history that matches substring in url for IE

5. Can I do dynamic partial match search like in Access (AutoExpand)

6. Search / Match hundreds of boolean fields

7. searching for a matching record in a recordset

8. searching a file for matching data

9. Text in a textbox, Search a database, display entries that match in a listbox

10. SQL queries on sql results

11. RegExp question: match within another match

12. Seek Nearest Match if exact match not found ?

 

 
Powered by phpBB® Forum Software