Null Query

WinDancer

Registered User.
Local time
Today, 03:37
Joined
Oct 29, 2004
Messages
290
I have a select query that works perfectly.

If the query is empty I want a messagebox that tells the user there is no matching record.

I can't seem to get the code to do this.

I have been working with the NZ() function but can't make it work...

Can someone get me started?

Thanks,
Dave
 
You can use a DCount on the form to check first:
Code:
If DCount("*","YourQueryName") = 0 Then
   MsgBox "There is no matching record.", vbInformation, "No Record"
Else
   DoCmd.OpenQuery "YourQueryName"
End If
Although I don't like opening queries direct (I use a form for them so there is more control over things).
 
Thanks, Bob. It runs perfectly :)
 

Users who are viewing this thread

Back
Top Bottom