Results 1 to 6 of 6
  1. #1
    coach32 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Aug 2011
    Posts
    47

    Adding Date to exported file not quite right

    I have the following code and I was hoping someone could let me know what I have missed as it gives me an error, saying that it is the wrong data type for one of the arguments.
    I'm using Excel and Access 2010. I am just trying to export a table to Excel that will have the Date tacked on at the end of the file name.



    Code:
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "tbl_SiebelAlert", "\\MEL21A001PPN\abn\CISC\Siebel Alert\SENT\Add Siebel Alert ", Format(Date, "ddmmyyyy"), True

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    change the , before Format to an &

    note you also need to include the file type (.xlsx)

    you may also want to consider changing the format to yyyymmdd so files can be easily ordered in the directory

  3. #3
    coach32 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Aug 2011
    Posts
    47
    Thank-you very much. Greatly appreciated.

  4. #4
    coach32 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Aug 2011
    Posts
    47
    I have updated the code to read
    Code:
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "tbl_SiebelAlert", "\\Siebel Alert\SENT\Add Siebel Alert ", & Format(Date, "dd-mm-yyyy") & "xlsx"
    I am receiving a "Compile Error: Expected: Expression" and the first '&' is highlighted.

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    reread my post and you will see what you haven't done

  6. #6
    coach32 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Aug 2011
    Posts
    47
    Sorry, I misread the comma for punctuation. All good now.
    Thank-you once again.

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

Similar Threads

  1. Replies: 3
    Last Post: 08-11-2015, 05:35 PM
  2. Replies: 4
    Last Post: 06-17-2014, 02:50 PM
  3. Formatting exported CSV file
    By oatsybob in forum Programming
    Replies: 3
    Last Post: 02-04-2013, 11:32 PM
  4. Replies: 5
    Last Post: 02-24-2012, 11:02 AM
  5. to open Exported Excel File
    By waqas in forum Programming
    Replies: 3
    Last Post: 10-16-2011, 12:33 PM

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