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

    exporting to csv with date in name

    I am trying to export to a csv and have the date in the name. How do I go about doing so without having to actually type everything up or changing the file name after the export?

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536

  3. #3
    mchadwick is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    71
    Alan, I tried to modify your code to do what I need to do, but I didnt have much luck. I am trying to export the data from a table not a report and when I tried to change to that I had no luck. I'm just way to green in this area right now. I have a very strong desire to get better though. I have a set location on the hard drive also (c:\import_export\exported) to put the file and I don't understand how the code is putting the file on the desktop. Mitch

  4. #4
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    Mitch;
    Upload your db to the forum. Indicate which table, and where you want the file to go, as well as how you would like it named. Additionally, before you upload the file, dummy up any confidential information. Only submit a sampling of your data and do a compact and repair to make the file as small as possible.

    Folks here will look at it and give you some solutions.

    Alan

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    theFilePath = theFilePath & reportName & "_" & Format(Date, "yyyy-mm-dd") & ".xls

    This is the relevant piece of information from alan's script. If you are taking the date you want in your csv from a field on a form it would be:

    theFilePath = reportName & "_" & Format(#" & forms!formname!fieldname & "#, "yyyy-mm-dd") & ".xls

    or

    theFilePath = reportName & "_" & Format(" & forms!formname!fieldname & ", "yyyy-mm-dd") & ".xls

    (I didn't test but I suspect it's the latter) this should give you a report with your reportname and a date stamp on it.

  6. #6
    mchadwick is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    71
    I have attached the DB along with the folder structure the way it uses it. In the folder "exported" I would like to spit out the data from the table "001-040 Final Table" as a csv file. I need to get the date the file was exported into the name. Right now, I can get it work, but it doesn't have the date. This is what I would like the file name to look like, but I will settle for any variant of formatting for this. "Export-09072011-784.csv" The 784 is just text, its constant. I really appreciate all your help and looking forward to learning how to do this! The attachment also contains sample data that can be imported into the db in the folder "to import".

  7. #7
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    Mitch,
    I looked over what you want. You will need to create a form to put a command button on it. Then you will have to build code similar to what I showed you earlier. I thought that it would be a good exercise for you to attempt it and found this tutorial. Using the tutorial, try it out and post back with any issues you have. I thought the tutorial was straight forward and matched your case very closely.

    http://www.databasedev.co.uk/exporti...-with-vba.html

    Alan

  8. #8
    mchadwick is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    71
    Thanks Alan, I'll play with it today.

  9. #9
    mchadwick is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    71
    Alan, thank you very much for your help. i was able to do exactly what I wanted to do based on the tutoring page you gave me. I really appreciate your help. Mitch

  10. #10
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    You are welcome.

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

Similar Threads

  1. Exporting records based on date
    By justinwright in forum Import/Export Data
    Replies: 35
    Last Post: 05-11-2011, 04:53 PM
  2. Exporting to PDF
    By Alaska1 in forum Access
    Replies: 4
    Last Post: 12-16-2010, 09:52 PM
  3. Exporting to Excel Date Stamped File
    By BED in forum Import/Export Data
    Replies: 1
    Last Post: 08-07-2010, 05:53 PM
  4. Date format exporting to txt
    By timpepu in forum Access
    Replies: 1
    Last Post: 04-20-2010, 08:20 AM
  5. Exporting Help
    By mrnikeswsh in forum Import/Export Data
    Replies: 11
    Last Post: 01-16-2010, 11:59 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