Docmd.transfertext to import data

min3010

Registered User.
Local time
Today, 00:33
Joined
Oct 14, 2007
Messages
10
Hi,

I have a VBA function to transfer data from a query to a text file. The code is as follows:

Public Function ExportUsage()

DoCmd.TransferText acExportDelim, "Usage_Export_Spec", "usagequery2", "C:\Usage.txt", No
MsgBox "Export Completed!"

End Function


However, I need to extend this as the tablename and filename are specified in this code. I need to be able to allow the user to be able to specify the tablename and filename dynamically in a user friendly way rather then mess about with the code to change the details to reflect exporting of different queries into different locations.

Does anyone no how to do this, perhaps i can pass parameters? if so, how?

Many Thanks
 
I think you can simply leave that option blank -

DoCmd.TransferText acExportDelim, "Usage_Export_Spec", "usagequery2", , No

???
ken
 
Im afraid this does not work, the table name and filename are required arguments!

Thanks
 
Maybe use 'docmd.OutputTo' instead?

:)
ken
 
You could try:

Code:
Public Function ExportUsage(strExSpec, strQry, strFileOut As String)

DoCmd.TransferText acExportDelim, strExSpec, strQry, strFileOut, No
MsgBox "Export Completed!"

End Function

and pass the values needed when you call the function.

Hope this helps.
 

Users who are viewing this thread

Back
Top Bottom