It is quite possible to write some VBA to generate a queryDef for use with a report, I will attach an example of creating a queryDef.
What I can't work out at the moment is how you arrive at the decision of what records to include.
Or is it just the one record?