Message box if no records

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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)
 
Back
Top