Results 1 to 2 of 2
  1. #1
    mchadwick is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    71

    CSV Export

    I have a database that is exporting a CSV. I would like to be able to add the date into the file name of hte CSV. Here is an example of the file name



    Export-03012011-Companyname.csv

    The date can actually be in any format obviously other than 00/00/000 becuase of the fact that it is a file and the slashes would through that way off.

    Any Ideas? It would be greatly apprecited.

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Here is some sample code that I use to export Access reports/queries to Excel. You can modify as needed, but it will show you how I add the date to the file name. This adds the current date to the file name.

    Code:
    Private Sub Command5_Click()
    On Error GoTo Err_Command5_Click
    Dim reportName As String
    Dim theFilePath As String
    Select Case Me.Frame6.Value
        Case 1
        reportName = "MonthlyActivity"
        End Select
     
    theFilePath = Me.txtfilepath.Value
    theFilePath = theFilePath & reportName & "_" & Format(Date, "yyyy-mm-dd") & ".xls"
     
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, reportName, theFilePath, True
    MsgBox "Look on your desktop for the report."
     
    Exit_Command5_Click:
        Exit Sub
    Err_Command5_Click:
        MsgBox Err.Description
        Resume Exit_Command5_Click
     
    End Sub
    Private Sub Command10_Click()
    On Error GoTo Err_Command10_Click
        Dim stDocName As String
        stDocName = "Rejects By Analyst"
        DoCmd.OpenReport stDocName, acNormal
    Exit_Command10_Click:
        Exit Sub
    Err_Command10_Click:
        MsgBox Err.Description
        Resume Exit_Command10_Click
     
    End Sub
    Alan

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

Similar Threads

  1. Trying to export to Excel
    By BigCat in forum Programming
    Replies: 19
    Last Post: 05-19-2011, 01:49 AM
  2. Export query to CSV
    By daniel.preda in forum Import/Export Data
    Replies: 3
    Last Post: 12-30-2010, 08:52 AM
  3. File Export
    By Kencao in forum Import/Export Data
    Replies: 3
    Last Post: 02-01-2010, 05:27 PM
  4. Export
    By vvasudev in forum Import/Export Data
    Replies: 2
    Last Post: 01-20-2010, 11:42 AM
  5. Export to MySQL
    By avincent in forum Import/Export Data
    Replies: 1
    Last Post: 12-19-2009, 09:48 AM

Tags for this Thread

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