Docmd.transfertext to import data (1 Viewer)

min3010

Registered User.
Local time
Today, 01:28
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
 

KenHigg

Registered User
Local time
Yesterday, 20:28
Joined
Jun 9, 2004
Messages
13,327
I think you can simply leave that option blank -

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

???
ken
 

min3010

Registered User.
Local time
Today, 01:28
Joined
Oct 14, 2007
Messages
10
Im afraid this does not work, the table name and filename are required arguments!

Thanks
 

KenHigg

Registered User
Local time
Yesterday, 20:28
Joined
Jun 9, 2004
Messages
13,327
Maybe use 'docmd.OutputTo' instead?

:)
ken
 

jubb

Registered User.
Local time
Today, 10:28
Joined
Jul 27, 2005
Messages
50
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

Top Bottom