PDA

View Full Version : How to display "No Results Found"



TronCarter
07-25-2008, 08:05 AM
I have a stored query that displays results on a form (The record source of the form is the query). It works great when there are results to be displayed, but if the query returns no results, the form is just blank and the end users get confused. How do I have it display "No Results Found" or perhaps "x number of results found" in the footer?

Tron

CreganTur
07-25-2008, 09:00 AM
Here's what I use:

for the On Load event, I use the DCount function to count the number of records in the query that the form works with. If the result of the the count is Null or Zero, then I display a MsgBox.

-FieldToCount would be the name of the field in the query you want to count (I generally count my Primary Key field)
-QueryName is the name of your query.
Dim cnt
cnt = DCount("FieldToCount", "QueryName")
Select Case cnt
Case Null
MsgBox "No Results Found."
Case 0
MsgBox "No Results Found."
End Select

TronCarter
07-25-2008, 10:55 AM
Worked great, thank you.

CreganTur
07-25-2008, 11:01 AM
Worked great, thank you.

Glad to help!

Also, forgot to say welcome to the forum- it's always great to see new faces! :clap:

If your issue is resolved, could you please use the Thread Tools link at the top of this thread to mark it as solved? Thanks :thumb