outputTo and whereCondition?

  • Thread starter Thread starter Jan
  • Start date Start date
J

Jan

Hi

I need to change the criteria of a query and then create a csv file with the
records that match the query. I have been trying to do this using the
DoCmd.OutputTo command. It would seem logical to use a whereCondition
statement to set the criteria for the query. Is this possible? Can anyone
tell me the syntax?

Thanks
J
 
Jan said:
Hi

I need to change the criteria of a query and then create a csv file
with the records that match the query. I have been trying to do this
using the DoCmd.OutputTo command. It would seem logical to use a
whereCondition statement to set the criteria for the query. Is this
possible? Can anyone tell me the syntax?

Thanks
J

OutputTo (as you have discovered) has no ability to dynamically apply a filter.
There are numerous work-arounds.

Have the query use a public variable or hidden form control for criteria and set
that to the desired value before calling OutputTo.

Modify the SQL of the query before the OutputTo and then set it back afterwards
(though the query could get stuck in the modified state). To avoid that you
could build a temporary "query over the query" and then put the filtering only
in the temp query (safer).

If you were using OutputTo against a form or report you can apply dynamic
filtering in the Open event based on a test that your OutputTo code can
manipulate before hand.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Access Open Form with WhereCondition 6
OutputTo Excel (A3K) 1
Access Dcount (multiple criteria) 3
OutputTo pdf error 1
WhereCondition newrecord 2
Output to CSV w/ OutputTo 14
WhereCondition in .OpenReport 3
specified criteria with outputto? 3

Back
Top