Can you provide a link to the page online? I want to see what is being outputted versus the code that you are using.
If the folder is opening in the browser instead of the file, it tells me that the value for the file is probably not making it to the binding in the link.
You may also want to attach the actual page here so we can see all the code including the recordset query. It seems like there may be a slight code error that is causing you the problem.