Error: Ad-hoc query could not be deleted. This ad-hoc query or a selection created from this ad-hoc query may be in use.
If a query (or selection based on that query) is in use anywhere in the program as part of a process or otherwise, the query cannot be deleted. If you attempt to delete a query that is in use, this message appears to inform you that the operation is not allowed. Delete the query from wherever it is in use.
Currently, there is no standard method of determining where a query may be in use. Consider what the query was created for and check those locations first.
Alternately, product development may be able to assist with specific instances: Contact Support and reference this article.