Hi,
What you need to do is to test whether the Reference No the user enters actually exists before running the query.
I would do this using DCount and if the count is 0 i.e. that reference number doesnt exist, give the message box message and not run the query or open the results form.
Add...