Select a Folder and file name to Save to

Posted on 2007-10-01
Last Modified: 2013-11-28

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.

Question by:d10u4v
    LVL 119

    Expert Comment

    by:Rey Obrero
    you will need the codes from here

    Author Comment

    Yeah, I have got them, but i need to allow the user to type in their own file name to 'Save As'

    LVL 19

    Expert Comment

    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.

    Author Comment

    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"

    LVL 119

    Accepted Solution


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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
    Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now