T
Tokyo Alex
Dear all,
I have a query set up and I export the results into a CSV file using
DoCmd.TransferText.
Sometimes this query returns no records. In that case I don't want to
export the CSV.
I can think of a couple of ways to do this:
1) Create a recordset object on the query, check if there are any records
and if so go ahead and export. However, this means running the query twice
(once to check recordcount and once to export) which is not efficient.
2) Change the query into a make-table query, use OpenQuery, export the
resulting table if rowcount is not 0 and then delete the table. This is a
bit clunky, but would work reasonably well (except that I may want at some
point to run the same query without making a table).
Can anyone think of a more elegant way to achieve this? Any suggestions
would be appreciated.
Thanks in advance,
Alex.
I have a query set up and I export the results into a CSV file using
DoCmd.TransferText.
Sometimes this query returns no records. In that case I don't want to
export the CSV.
I can think of a couple of ways to do this:
1) Create a recordset object on the query, check if there are any records
and if so go ahead and export. However, this means running the query twice
(once to check recordcount and once to export) which is not efficient.
2) Change the query into a make-table query, use OpenQuery, export the
resulting table if rowcount is not 0 and then delete the table. This is a
bit clunky, but would work reasonably well (except that I may want at some
point to run the same query without making a table).
Can anyone think of a more elegant way to achieve this? Any suggestions
would be appreciated.
Thanks in advance,
Alex.