Results 1 to 2 of 2
  1. #1
    FinChase is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    20

    Get Export File name from Unbound Text Box

    I have a query that I want to allow users to automatically export to Excel. I have a macro set up that uses the TransferSpreadsheet function and sets the path. However, I'd like to further automate it by using a unique name for each spreadsheet saved as I will have several users exporting files to the same folder.



    I would like to have the user enter the name in a text box, such as Doe, John. This is simply entered on a form that is used to provide criteria for the queries that are run. Nothing from the form is written to any of the tables. Is there a way to pull the data in the unbound text box and use that as the file name. In my example, I'd like to see the file name be Doe, John.xls.

    Any help is appreciated!

  2. #2
    FinChase is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    20
    Never mind. I figured out an answer, using the code below, in case anyone else needs it:

    Private Sub cmdKS_Export_Click()
    On Error GoTo Err_cmdKS_Export_Click
    Dim strMyPath As String
    Dim strEEName As String
    strMyPath = "Q:\Client Name\Open Enrollment\2012\Rates\Retirees\Retiree Estimates Database\Archive\"
    strEEName = strMyPath & Me.txtLName & ".xls"
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "qryKS_All Plan Options_CalcCost", strEEName, True, ""

    Exit_cmdKS_Export_Click:
    Exit Sub
    Err_cmdKS_Export_Click:
    MsgBox Err.Description
    Resume Exit_cmdKS_Export_Click

    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. trying to export data to a text file
    By itm in forum Access
    Replies: 1
    Last Post: 06-30-2011, 10:40 AM
  2. Replies: 1
    Last Post: 06-09-2011, 11:10 PM
  3. Export to Text File Using DoCmd Access 2007
    By tonere in forum Programming
    Replies: 1
    Last Post: 03-30-2011, 06:14 PM
  4. How do you export a file with a unique file name
    By Budman42 in forum Import/Export Data
    Replies: 1
    Last Post: 10-15-2006, 06:10 PM
  5. Unbound text box truncating text
    By gddrew in forum Forms
    Replies: 0
    Last Post: 03-02-2006, 11:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums