Export UnionSQL query (1 Viewer)

ronda

Registered User.
Local time
Today, 12:54
Joined
May 5, 2002
Messages
19
I am trying to export the result of my sql query to a ;delimited format. I already know how to do it manually (File-Export) - is there a way to automate it?
 

Jon K

Registered User.
Local time
Today, 12:54
Joined
May 22, 2002
Messages
2,209
The following TransferText method exports from a query and creates a comma delimited file C:\Sales\July.txt with field names:

DoCmd.TransferText acExportDelim, , "qrySales", "C:\Sales\July.txt", True


To have a semi-colon delimited file, you can save a specification name from File, Save As/Export... and type the name in quotes in the second argument in the method.

See Help on TransferText action and method for more info.
 

ronda

Registered User.
Local time
Today, 12:54
Joined
May 5, 2002
Messages
19
Hi Jon - thanks for the response.

I tried using the transfer text method - but it seems you can only use those on select queries - I am doing a (sql) union query. Any other thoughts or suggestions?
 

Jon K

Registered User.
Local time
Today, 12:54
Joined
May 22, 2002
Messages
2,209
The query "qrySales" in my example is in fact a union query and the TransferText method works when it is run from the click event of a command button on a form.

Does your union query work properly when you open it?

Was the file path for the txt file correct?

If the problem persists, you can create a new select query based on the union query and export it using the TransferText method.
 

Users who are viewing this thread

Top Bottom