• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

Select a Folder and file name to Save to

Hi,

I have this code:

DoCmd.TransferText acExportDelim, , "tblData", "C:\Documents and Settings\Desktop\text.csv"
MsgBox "Conversion/Export completed!", vbInformation, "Export CSV"

Which succesfully create a CSV file from tblData.  However, what i would like to be able to do is get the user to select the folder in which they want to save the file in AND select a file name, instead of having the code doing it automatically 'C:\Documents and Settings\Desktop\text.csv'.

I have this code which lets the user select the folder:

Private Sub FindFolder_Click()
Dim spath As String

   Folder.Value = ""
   
  'The call can not have a trailing slash, so
  'strip it from the path if present
   spath = UnqualifyPath((FolderLocation.Value))
   
  'call the function, returning the path
  'selected (or blank if cancelled)
   Folder.Value = BrowseForFolderByPath(spath)

End Sub

I hope some one can help me with this matter.

Regards,
Anthony
0
d10u4v
Asked:
d10u4v
  • 2
  • 2
1 Solution
 
Rey Obrero (Capricorn1)Commented:
you will need the codes from here

http://www.lebans.com/callbackbrowser.htm

A2KCallbackBrowse.zip
0
 
d10u4vAuthor Commented:
Yeah, I have got them, but i need to allow the user to type in their own file name to 'Save As'

Anthony
0
 
frankyteeCommented:
a cheap and quick way to replace the filename argument
"C:\Documents and Settings\Desktop\text.csv"
is to simply let the user enter it into a textbox and then check that the directory exists (using dir function) before using the docmd method.
or just use the windows common dialog box.
0
 
d10u4vAuthor Commented:
How do i join two variables together in code.  For example, if i have a text box which will have the directory and file name in [Text1], and have another text box [text2] which will have the user entered file name, hoe can i join them together in the transfer code:

DoCmd.TransferText acExportDelim, , "tblData", "ENTER THE TWO VARIABLES HERE"
MsgBox "Conversion/Export completed!", vbInformation, "Export CSV"

Anthony
0
 
Rey Obrero (Capricorn1)Commented:

DoCmd.TransferText acExportDelim, , "tblData", me.text1 &"\"& me.text2
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now