EXPORT CSV with an AUTO NAME

  • Thread starter Thread starter ECEUK
  • Start date Start date
E

ECEUK

Guest
Hi all

Dead easy !!!!

I have a macro that exports data to a specific folder. However, I HAD to give the exported csv file a name to differenciate it from the other files that I export.
Q:
Is it possible to name an exported file (ie its title) from data in a query or table ie. [Customer Name]

More Specific Detail:

I have a visual LIST of customers on a form. When I select a customer and press my print button.... (through a series of queries).....it prints me a report specific to that customer.

What I want it to do is for it to also send the data (csv) to a folder with THAT customers name !!!!

Come to think of it being able to autoname things (Tables/Queries etc) would be great. EG when I set up a new customer I could press a button and it automatically creates a query, specific to that company ??????

Cheers
Ellis
 
You can do all that using VBA instead of macros

Regardz
 
I need to do something similar to this as well.
When I automate the export my csv file, I need to include one field from a qry into the file name. Can you explain how best to do that with VBA?
 
Geperz this is an old one,

OK here goes, something like so:

Code:
dim AString as string
Dim rst as dao.recordset ' read the faq on ADO vs DAO and on References!
Set rst = currentdb.openrecordset("queryName")
aString = rst![YourField]
set rst = nothing
docmd.TransferText acexportdelim,"SpecName","TableName","C:\Test" & AString & Format(date,"YYYYMMDD") & ".csv"

Check the access help for what you need to know about the transfertext command.

Regardz & GL
 

Users who are viewing this thread

Back
Top Bottom