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?
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?
See my response here:
https://www.accessforums.net/access/...ort-16887.html
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
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
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.
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".
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
Thanks Alan, I'll play with it today.
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
You are welcome.