The requested bit
Code:
FileCopy OldName, NewName
[Link] = NewName & "#" & NewName & "#"
intDeleteFile = MsgBox(MoreText, vbYesNo, "Delete?")
If intDeleteFile = vbYes Then
On Error GoTo DeleteError
Kill OldName
End If
EOBEntry:
If Me.FileType = "EOB" Then
Application.FollowHyperlink NewName
intEmptyFile = MsgBox(txt, vbYesNo, "EOB Entries")
If intEmptyFile = vbYes Then
DoCmd.OpenForm "FileList_Patient Entry", , , , acFormEdit, , Me.[Accession Number]
Else
DoCmd.OpenForm "FileList_Patient Entry", , , , acFormEdit, acWindowNormal
End If
End If
Exit Sub
DeleteError:
If Err.Number > 0 Then
Err.Clear
intEmptyFile = MsgBox("Delete was unsuccessful." & vbCrLf & "Please close the file you wish to delete and click OK.", vbExclamation, "Delete Error")
On Error GoTo DeleteFinal
Kill OldName
DeleteFinal:
If Err.Number > 0 Then
intEmptyFile = MsgBox("Delete was unsucessful." & vbCrLf & "Please delete the file manually.", vbCritical, "Delete Error")
End If
GoTo EOBEntry
End If
End Sub
The GoTo was so that the code could go back to a point before "Exit Sub" and to separate the error coding from the rest of the code.