Run some code in the form's Open event (air code, not tested):
Dim db As Database, rs As Recordset, strSQL As String
Set db = CurrentDb
strSQL = "Select * From MyQuery"
Set rs = db.OpenRecordset(strSQL)
If rs.RecordCount = 0 Then DoCmd.Close acForm, Me.Name
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
"MyQuery" is the name of the query the form is based upon.
HTH - Keith.
www.keithwilby.org.uk
"A.J.M. van Rijthoven" <to***@xs4all.nl> wrote in message
news:4s********************************@4ax.com...
I want to open a form that is based on a query. When the output of the
query results in 0 records, I don't want to open the form but just
display a messagebox. Is there a way to check if the result of the
query = 0 records??