troubleshooting Question

do not delete if error

Avatar of Shawn
ShawnFlag for Canada asked on
Microsoft Access
2 Comments1 Solution176 ViewsLast Modified:
The code below copies a file and renames it in a new folder. Right now the old file is deleted right away but I only want to delete it if the copy suceeded.

Private Sub btnAttributeAll_Click()

Dim SourceFile, DestinationFile
SourceFile = "G:\Scans\Scan - 262i\test.jpg"    ' Define source file name.
DestinationFile = "G:\Scans\test moved\testmoved.jpg"    ' Define target file name.
FileCopy SourceFile, DestinationFile    ' Copy source to target.

Kill SourceFile
MsgBox "moved file " & SourceFile

End Sub

How would I do this?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros