Message box if no records

G

Guest

Hello.
I have a form which has its data source in a query... and this query has a
criteria to filter the records...
When I open the form, if the query returns no records at all, that record
opens with no records.
My question is: it it possible to check the query, and if the query returns
at least one record, then open the form to show it; but if que query returns
no records, the form doesn't open, and is showned the message «No records
were found».
Thanks in advance.
Best regards.
Acores
 
S

Steve

Change your code where you now open the form to:

If DCount("*","NameOfYourQuery") = 0 Then
Msgbox "No Records Were Found"
Else
DoCmd.OpenForm "NameOfYourForm"
End If


PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
G

Guest

Thanks, Steve. Your solution worked just fine...
Best regards.
Acores

"Steve" escreveu:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top