Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameter query

Status
Not open for further replies.

vistor

Technical User
Dec 22, 2000
164
US
Hi,

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?

Thanks
 

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top