Hi Chip.
You're confusing the currently open version of your Report object with the one referred to in
DoCmd.OutputTo()
.
One is open already. This is simply an instance, or copy, of the original design held as [Export Potential Client Report]. The other is a simple reference to the design itself - NOT your open instance.
So, what you see on the screen is affected by your changing its
RecordSource
. The one that you want
DoCmd.OutputTo()
to sned as a file is certainly not.
Let's get back to a simpler approach and remember that the Report object is based off a table or query and that's the data you want saved - not anything in the report itself - just the data. That's best done using the following template code :
- Call DoCmd.TransferText(TransferType:=acExportDelim _
-
, TableName:={Name of table or query} _
-
, FileName:={Name of file to hold data})
You'll have noticed that this doesn't filter the results for you any more than trying to do it by Report did.
I don't think there's an easy way to do that in code but you can create a Query (QueryDef) that filters based on a value stored in one of those database variables whose name I just can't dig up ATM.
You can also create a new QueryDef in code if you need to but I'll get to that another time.