Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Overwrite or Create copy of file when saving?

Posted on 2009-04-30
4
Medium Priority
?
326 Views
Last Modified: 2012-05-06
I have code that is saving my Access report as a PDF on local disk space.
Currently, when a user presses the save proposal button it overwrites any PDF that already has it's same file name.  The user does not get the option to change the file name.

I would like to add some code that checks to see if the output file name already exists and if it does, ask the user if they'd like to overwrite the file or create a copy of it.  If they choose copy it would concatenate a "copy of" to the beginning of the file (just like windows).   I've provided my variables below.

Thanks!

dim outputfile as string
dim destinationpath as string
 
destnationpath = "c:\files"
outputfile = destpath & Forms!frmtabs!txtFilename & ".PDF"

Open in new window

0
Comment
Question by:GWitek
  • 3
4 Comments
 
LVL 3

Accepted Solution

by:
DRY_GIN earned 2000 total points
ID: 24276078
you can use if (len(dir(filename))>2) then 'ask for the question
or you can use scripting dll

If  CreateObject("Scripting.FileSystemObject").FileExists(your_file) Then 'ask question
0
 
LVL 3

Author Comment

by:GWitek
ID: 24389090
Will one of these be better or worse then the other?
What does the ">2" do in the first example?
0
 
LVL 3

Author Comment

by:GWitek
ID: 24704296
I'm revisiting this project.
Any suggestions on the above questions?
Thanks,
0
 
LVL 3

Author Closing Comment

by:GWitek
ID: 31576696
Works awesome!

Thanks!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question