Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If SQL returns no results..dataset becomes invalid...then error

Status
Not open for further replies.

DizzyMonster

IS-IT--Management
Jul 9, 2000
2
0
0
GB
Hi,<br>&nbsp;&nbsp;&nbsp;Hope someone can help me. I have a find button that returns the results from a user entered box. Everything is fine if the SQL statement retrieves something and sets the Dataset to something....When it doesn't it crashes as 'no Record Selected' how can I trap it and stop it doing this???<br><br>Thanks.
 
The answer to your problem is:<br><br>Put in a test for both BOF and EOF for the recordset, if both are true then no records have been found, and you can exit the the sub or do whatever..<br><br>Something like this<br><br>If RS.EOF And RS.BOF Then...<br><br>This traps the no record selected,just as you wanted too !!<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top