Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check Before Overwriting Files 1

Status
Not open for further replies.

MattGreer

Technical User
Feb 19, 2004
471
US
I wrote a little VBA script to export PDF reports from MS Access 365. It works fine except for the fact that it doesn't prompt me if it's going to overwrite an existing file. I would like to get a warning before it overwrites a file and only to proceed if I click 'OK'.

Currently the line of code I'm using to output the report is:

DoCmd.OutputTo acOutputReport, stReportName, acFormatPDF, stDocName

Where (I know you all already know this but just in case):
acOutPutReport - tells Access that it's a Report-type object
stReportName - of the name of the Report object in Access
acFormatPDF - the format the report should have, in this case PDF
stDocName - the full folder path and file name of the output PDF file

I looked at the DoCmd.OutputTo method syntax but didn't see anything regarding checking for an existing file before writing the file to the folder. What do I need to modify to have Access perform this check?

Thanks!!

Thanks!!


Matt
 
Use Dir(stDocName) to check if file exists before executing DoCmd.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top