Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export Question

Status
Not open for further replies.

PeterL

IS-IT--Management
Oct 30, 2000
129
US
I have a macro which exports data as a comma delimited file to a directory. The file name and directory are hard coded. I would rather have the program prompt the user for a file name and location to save this file. I assume I would "filedialog" but am not sure how to construct this.

Thanks
 
Actually what I'd really like to do is us the DoCmd.Transfertext function where I decide the location to save the file but the file name comes from a field in the selection query.

Any thoughts?
 

This simple method exports to an excel format, but in your case, just use the TranserText arguments. This sample refers to two textboxes on a form. In this case the path is chosen from a popup browse dialog, as Zameer suggested, and the file name is entered by the user.

Dim strPath As String
strPath = Me.txtPath

Dim strFileName As String
strFileName = Me.txtFileName

Dim strFullPath As String
strFullPath = strPath & strFileName

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryName", strFullPath

-----------------------------------------------

But if you want to hard coded the location, you can use strPath = "c:\somewhere\"(not recommended), or pick up the location path by referencing a form control, which can come from your query.

Mike Dorthick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top