Access 2010; macro setwarnings is set to no but the ExportWithFormatting to a text file still prompts to overwrite an existing file

I have a database with a macro that runs in Access 2003 which generates a new table then exports it to a text file. I am upgrading the database to Access 2010 and have run into an issue exporting to the text file automatically. My test macro is as follows:
SetWarnings = No

ExportWithFormatting

  Object Type: Table

  Object Name: DataTable

  Output Format: Text Files (*.txt)

  Output FIle: C:\Temp\DataTable.txt

  Autto Start: No

  Output Quality: Print

 

After running the macro once every time I run it after that I get "The file C:\Temp\DataTable.txt already exists. Do you want to replace the existing file? Yes, No".

 

Any insights on how to enable this in a macro would be apprectiated.

 

Art

Answer
Answer
I'd agree with John that deleting the file first, if it exists, would be a good solution.  You'd probably need to call a function to do this, so add the following function to a standard module:

Public Function KillTempFile()

    ' delete temporary file, ignoring error if file doesn't exist
    On Error Resume Next
    Kill "C:\Temp\DataTable.txt"

End Function

You can then call the KillTempFile function from your macro with the RunCode action.

_____________________
Ken Sheridan,
Newport, Shropshire, England

"Don't write it down until you understand it!" - Richard Feynman

9 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated January 13, 2024 Views 8,566 Applies to: