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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Queries No Result Message

Status
Not open for further replies.

kilando

Programmer
May 29, 2003
12
CA
Hi Everyone,

I'm new to Visual Basic and I'm basically using it to write an interface for use with a Microsoft Access 2000 Database that I've been developing.

My question is: how can I get a VB script that will send a message to the user (via a message box) that informs the user that the query preformed had no results in the database?

Basically I have a DB of records or artifacts. One of the options is to search for a specific artifact in the Database. I'd like something that sent a message to indicate that there was no result rather than displaying a blank form or report.

Thanks

 
I am not sure if you are trying to use VB or VBA.
The best way , I think , it is to test if your recordset is empty.

rst.open

if rst.ROF then
msgbox "No records"
else
do while not rst.eof
'do report
loop
end if

rst.close

Something like this.
In case of VBA, the report has an event named NODATA.
You can use that event.

Success
 
<if rst.ROF then >

should probably read:
if rst.EOF then


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Yes, I do too. It's a good defensive programming technique, not to mention it's easier for the poor propellerhead that has to make sense of your code after you've made your millions and retired to Alaska.

Bob
 
Thanks for the help everyone, this has pretty much solved the probelm for now (although I'm sure something else will come up.)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top