Hi Jim
First of all, let me say I love your code. It's clean, properly indented and easy to follow. Over the course of my carrier, I've rarely see this quality.
Let's debug this thing to find what the real error is.
Put a break on the line retval = 0
When the code breaks open the Immediate window (Ctrl+G). Check the DLookup output to make sure it is doing its job in finding what you want. A simple Debug.Print will print out the value in the Immediate Window.
Hover your mouse pointer over "Target" and "Source" to make sure their values are exactly what you were expecting. It looks like it should work as is, but it's important to double-check just to make sure.
Are there any surprises?
Regards,
Bill Mosca
From: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io> On Behalf Of Jim Wagner
Sent: Tuesday, January 11, 2022 7:07 AM
To: MSAccessProfessionals@groups.io
Subject: [MSAccessProfessionals] Error 70 permission denied
Hello all,
This morning i ran a piece of code that has been working for quite a long time and today i received a runtime error 70, Permission denied.
when I debug it is on
retval = objFSO.CopyFile(Source, Target, True)
the source is a network folder
I tried changing the location to a folder on my c drive but I received the error anyway. It is part of an If statement but this has been working for a year now. Has there been another update that has caused this?
Is there something i need to change or is this a permanent situation?
Thank You for any advice offered.
Jim Wagner
Here is my code below
Dim varX As Variant
If DLookup("[RunReportDate]", "[tblPayDates]", "[RunReportDate] = Date()+1") Then
MsgBox "The Hyperion dates will be changed and a copy of the database is being created. be patient until the message declares the database copy has completed"
Dim Source As String
Dim Target As String
Dim retval As Integer
Source = CurrentDb.Name
'This is the only thing to change - add the path of where you want the file to save here
'Target = "W:\ADMINISTRATIVE SERVICES DATABASES\MANAGEMENT SUPPORT SERVICES T-A-P\PAYROLL RECONCILIATION DATABASE\Archive\Backup_Payroll_Reconciliation_Database_"
Target = "C:\DirectReports\Backup_Payroll_Reconciliation_Database_"
Target = Target & Format(Date, "mm-dd") & ".accdb"
' create the backup
retval = 0
Dim objFSO As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
retval = objFSO.CopyFile(Source, Target, True)
Set objFSO = Nothing
'Opens the folder of the file you just created
'Application.FollowHyperlink "W:\ADMINISTRATIVE SERVICES DATABASES\MANAGEMENT SUPPORT SERVICES T-A-P\PAYROLL RECONCILIATION DATABASE\Archive\"
Application.FollowHyperlink "C:\DirectReports\"
MsgBox "Process has completed. " _
& vbCrLf & vbCrLf _
& "The database has been backed up into the Archives folder with the current date for example " _
& "Backup_Payroll_Reconciliation_Database_09-03" _
& vbCrLf & vbCrLf _
& "The folder has opened for you to review the copied database", vbInformation, "Database Process"
Else
MsgBox "Data has updated"
End If
Tidak ada komentar:
Posting Komentar