I use code like this, combined with comboboxes to select the output (reports, exports, etc), to allow the user filter their choice of reports dynamically with none of the risks associated with users creating their own queries.
Very useful code, it lets you filter on as many fields as you want...