I know you can cancel a report if there isn't any data by using the On No Data event. Is there anyway to cancel a query if there isn't any match to the parameter criteria?
I assume you don’t want to open a form if there is no matching data. The easiest way to do it is define a recordset based on that parameter and test to see if you get back anything. You can do it from the on open event of the form since this event can be cancelled. This will work in your on open even. Assume you want to know if you have shipments scheduled to go out tomorrow:
Dim rs as recordset
Dim strsql as string
Strsql = “select * from tblOrderswaiting where shipdate = “ & date + 1
Set rs = currentdb.Openrecordset (strsql, dbopensnapshot)
If rs.recordcount = 0 then
Msgbox “No shipments scheduled”,vbinformation
Cancel = true
End if
Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.