Message box if no records

A

acores

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
[email protected]
 
A

acores

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

"Steve" escreveu:
 
Top