Adding Date to Exported File

D

Danu

I am using DoCmd.TransferSpreadsheet to move a file into Excel from Access.
This will be done daily so the date must be associated with the file name.
Each time I compile the module, I get a CONSTANT EXPRESSION REQUIRED error.

This is the output line:

Const OUTPUT_PATH = "P:\Reports\Daily File for " & Format(Date, "Long Date")
& ".xls".

FORMAT is highlighted after compiling. I'm new to this so it is probably
something obvious that I am doing wrong.

Please help and thank you.
 
J

Jeanette Cunningham

Danu,
this message is Access trying to tell you not to use a constants for the
output path.
Because the Date changes every day at least, it can't be a constant.
Change the path from a constant to a string variable.

Dim strOutpathPath as String
strOutpathPath = "P:\Reports\Daily File for " & Format(Date, "Long Date")
& ".xls".

Jeanette Cunningham
 
D

Danu

Thank you, Jeannette. That worked!
Can you suggest a beginner's "manual" to learn this facet of Access?
 
J

Jeanette Cunningham

Danu,
I'm not sure which facet of access you mean.
It's hard to recommend books, as different people have different ways of
learning.
Personally I learned a great deal from 2 books by John L Viescas called
Microsoft Office Access 2003 and Building Access Applications.
Both these books have several sample databases of many different types with
code that is well very well explained. I learned a lot from seeing how these
samples used code.

Jeanette Cunningham
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top