Adding date to outputted file name returning error.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using a macro (transferspreadsheet) to export a report from access to
excel. I require the outputted file to include todays date, so i have defined
the file name as:

C:\"Report"&Format(Date,"mmddyy") & ".xls"

When I run the macro an error is displated:

Cannot Update. Database or object is read only.

If I run the macro without the date formatting (i.e.C:\Report.xls) it works
OK. Anyone know a reason for this and how to fix.

Thanks
 
Thanks very much for your reply James, however I am still getting "Cannot
Update. Database or object is read only."
 
Yeah so am I, not sure why. Have tested and this works in VBA though,
you could stick it behind a command button on one of your forms.

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"TableName", _
"C:\Report" & Format(Date, "mmddyy") & ".xls", True

Sorry macros are not my area so possibly you are not allowed to use
functions like 'Format' in them.

James
 
Will try that. Thanks for your help

James said:
Yeah so am I, not sure why. Have tested and this works in VBA though,
you could stick it behind a command button on one of your forms.

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"TableName", _
"C:\Report" & Format(Date, "mmddyy") & ".xls", True

Sorry macros are not my area so possibly you are not allowed to use
functions like 'Format' in them.

James
 
Back
Top