I am receiving the error above when I am trying to move file locations from within Access. Files are being moved from a local computer location to a shared server location. The file types will vary but will be, for the most part, PDF PowerPoint or Excel. I have run through the process that is causing it a couple times now and it is about a 50% occurrence of the issue.
Is it possible the error is being thrown because the file to be moved is open in one way or another? Every time I have tested, the file to be moved was NOT open at all and the error was given. I'm fairly confident I have open permissions because the database is being used by a lot of people, or will be eventually.
Any ideas of what could be causing this to happen? The code is below.
Is it possible the error is being thrown because the file to be moved is open in one way or another? Every time I have tested, the file to be moved was NOT open at all and the error was given. I'm fairly confident I have open permissions because the database is being used by a lot of people, or will be eventually.
Any ideas of what could be causing this to happen? The code is below.
Code:
Private Sub cmdCheckThreePanel_Click()
Dim sMyPath As FileDialog
Dim sPath As Variant
Dim strFolderPath As String
Dim strMessage2, strTitle2 As String
Dim fname As String
Dim strFile As String
Dim Response As String
Dim strBodyNo As String
Dim InputYear As String
Dim Response2 As String
Dim strFile1 As String
On Error GoTo Error_Handle
strBodyNo = Me.BodyNo
strMessage2 = "Would you like to open the file?"
strTitle2 = "Open Three Panel"
Set sMyPath = Application.FileDialog(msoFileDialogOpen)
strFolderPath = Me.FolderPath
'Debug.Print "Looking for: " & strFolderPath & "*" & strBodyNo & "*"
strFile = Dir(strFolderPath & "*" & strBodyNo & "*")
'While (strFile <> "")
'Debug.Print strFile
If strFile <> "" Then
Response = MsgBox(strMessage2, vbYesNo, strTitle2)
If Response = vbYes Then
While (strFile <> "")
Application.FollowHyperlink strFolderPath + strFile
strFile = Dir()
Wend
End If
Else
MsgBox "No Three Panel found for this Body No", , "No File"
Response2 = MsgBox("Do you have a Three Panel for this Body No?", vbYesNo + vbQuestion, "No File")
If Response2 = vbYes Then
'MsgBox "Please add Three Panel to: " & Chr(13) & Chr(10) & Me.FolderPath
With sMyPath
.AllowMultiSelect = True
.Title = "Open File"
.ButtonName = "MOVE"
If .Show Then
'MsgBox "Moving " & .SelectedItems(1) & " to " & strFolderPath
strFile1 = Right(.SelectedItems(1), Len(.SelectedItems(1)) - InStrRev(.SelectedItems(1), "\"))
'MsgBox strFile1
FileCopy .SelectedItems(1), strFolderPath + strFile1
MsgBox "Move Successful"
If MsgBox("Is this an Initial Three Panel Result?", vbYesNo + vbQuestion) = vbYes Then
Me.cboInitialThreePanel.Value = "Yes"
ElseIf MsgBox("Is this a Final Three Panel Result?", vbYesNo + vbQuestion) = vbYes Then
Me.cboFinalThreePanel.Value = "Yes"
End If
strFile1 = Dir(strFolderPath & "*" & strBodyNo & "*")
If MsgBox(strMessage2, vbYesNo, strTitle2) = vbYes Then
Application.FollowHyperlink strFolderPath + strFile1
End If
Else
MsgBox "Action Cancelled"
End If
End With
Else
MsgBox "Ask Supplier for Three Panel"
End If
End If
Exit Sub
Error_Handle:
MsgBox "Error: (" & Err.Number & ") " & Err.Description, vbCritical
Exit Sub
End Sub