i have a form which has as button that opens a query
how can i make it so that if there arent any results from the query then a error message will pop up saying "no results found" and the table dosent show?
You need to test the DCount in the code that runs from your button. Look at Access help on DCount. You usually build the parameters for DCount so that it returns the same dataset as your query.
"if the criteria dosent match anything i want the error message box to come up"
it will. if the query works the way you want then...it works all the time. ask the query how many records there are any time you want. if there are records, do something. if there are no records supply the msg.
if you are saying you want to *change* the criteria every time that's different (and you haven't said this).
if you're not sure what neil's talking about you should search this site. not trying to be difficult - there are several threads discussing this and it'll probably be faster to search.