UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Kill Raising Error 75 On Some Files, Access 2013    
 
   
JHolm
post Nov 27 2017, 07:26 PM
Post#1



Posts: 73
Joined: 7-July 15
From: BC Canada


Hi All,

I'm using the procedure below to move files to a new folder and delete them from the original location. A description and the path of each file to be moved is in listbox lstAddDocs on form frmDocuments. The objective is to link scanned documents to a piece of equipment in the database. As the link is created the documents are copied out of the Scans folder and then deleted so they don't clutter it up.

CODE
Public Sub AddDocs()
    Dim frm As Form
    Dim i As Integer
    Dim iI As Integer
    Dim iL As Integer
    Dim sPath As String
    
    On Error GoTo AddDocs_Err
    
    Set frm = Forms!frmDocuments

    For i = 0 To frm.lstAddDocs.ListCount - 1
        'Create destination path
        iI = InStrRev(frm.lstAddDocs.Column(1, i), "\")
        iL = Len(frm.lstAddDocs.Column(1, i))
        sPath = "\\ACCOUNTING\Data\Capital Asset Documents" & Right(frm.lstAddDocs.Column(1, i), iL - iI + 1)
    
        'Copy file and delete original
        FileCopy frm.lstAddDocs.Column(1, i), sPath
        Kill frm.lstAddDocs.Column(1, i)
        
        'Create record in table
        CurrentDb.Execute "INSERT INTO tblDocuments (TransID, DocDescription, DocLink) " & _
                          "VALUES (" & frm.txtTransID & ",'" & frm.lstAddDocs.ItemData(i) & "','" & sPath & "');"
    Next i
    
    GoTo AddDocs_Exit
    
AddDocs_Err:
    If Err.Number = 75 Then
        MsgBox "Unable to delete " & frm.lstAddDocs.Column(1, i) & vbNewLine & vbNewLine & "Please delete manually.", vbOKOnly + vbExclamation, "Delete Failed"
        Resume Next
    End If
AddDocs_Exit:
    Set frm = Nothing
End Sub


I originally designed it with PDF's in mind, but it should really work with any file type.

One of the users has started trying to use it to link JPG's instead of PDF's.

It works flawlessly with PDF's but every time a JPG is linked it raises error 75, "Path/File access error (Error 75)" at the Kill statement.

I did try to Google it, and found several people with error 75 issues, but nothing really similar enough to help me out.

I am now trapping the error so the code doesn't simply fail, and I haven't tried it with any other file types yet, but does anyone have any idea why that's happening?

I'm just heading home but I'll check back tomorrow.

Cheers,

Jeff
Go to the top of the page
 
DanielPineault
post Nov 27 2017, 09:50 PM
Post#2


UtterAccess VIP
Posts: 5,454
Joined: 30-June 11



I don't know what the root issue is, but I'd start by adding a DoEvents between the copy and the deletion. I might also try creating a loop after the copy the check that the file was copied and wait until it is before moving on to trying to delete it. But these are just stabs in the dark.

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...
Go to the top of the page
 
JHolm
post Nov 28 2017, 11:50 AM
Post#3



Posts: 73
Joined: 7-July 15
From: BC Canada


Thanks Daniel. Both those suggestions worked thumbup.gif

It must take Windows longer to copy a JPG than a PDF for some reason.

Cheers,

Jeff
Go to the top of the page
 
DanielPineault
post Nov 28 2017, 12:08 PM
Post#4


UtterAccess VIP
Posts: 5,454
Joined: 30-June 11



Glad it was this simple.

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    18th December 2017 - 03:49 AM