put the download link on one page, have it go to a download page. On the download page, create the recordset and add the download file server behavior.
You can set the download file server behavior to only trigger if the recordset is Not empty. Also add an error to the download page to show if the recordset is empty.