Thanks to a lot of help from this forum over the years I have a form with a button that copies files listed on the form from one folder to another on my computer. Was working perfectly until I got a new computer. I made absolutely sure that the file locations for the files I need to copy stayed the same, along with the destination folder. But now my code isn't working. I am not a code expert, I had a lot of help with this. Can someone look it over and see what could possibly be happening? I'm getting 'the path could not be found' message. The field that contains the file path is called PDFLocation, and here's an example of a file path:
C:\Users\Anne\Dropbox\Account Specific\Kroger\0 11110 02817 4 Kroger Greek Nonfat Yogurt Plain 32oz.pdf. It may be important to note that in the error message the path that could not be found is shown as '0 11110 02817 4 Kroger Greek Nonfat Yogurt Plain 32oz.pdf' without the start of the path.
C:\Users\Anne\Dropbox\Account Specific\Kroger\0 11110 02817 4 Kroger Greek Nonfat Yogurt Plain 32oz.pdf. It may be important to note that in the error message the path that could not be found is shown as '0 11110 02817 4 Kroger Greek Nonfat Yogurt Plain 32oz.pdf' without the start of the path.
Private Sub CopyPDFcmd_Click() |
Dim rs As DAO.Recordset |
Set rs = Me.RecordsetClone |
Do Until rs.EOF |
CopyMyPdf (rs!PDFLocation) |
rs.MoveNext |
Loop |
Set rs = Nothing |
End Sub |
Private Sub CopyMyPdf(strFile As String) |
Dim Source As String |
Dim Destination As String |
Dim strName As String |
Source = strFile |
strName = Mid(Source, InStrRev(Source, "\") + 1) |
Destination = "C:\Users\Anne\Dropbox\SubmissionPDFs\" & strName |
On Error GoTo ErrorHandler |
FileCopy Source, Destination |
ErrorHandler: |
If Err.Number = 76 Then |
MsgBox "The path '" & strName & "' could not be found. Please validate the" & _ |
" location and name of the specifed file and try again." |
End If |
End Sub |