Code to add Attachment to Email (If attachment is in its location) (1 Viewer)

tucker61

Registered User.
Local time
Yesterday, 18:11
Joined
Jan 13, 2008
Messages
217
My code creates a email and attaches some images to the email.
The images are stored in File_Location folder.
The hyperlink to the images are stored in the TblQcFiles table.

Some of the images have been archived into sharepoint, so are no longer in the folder, but the hyperlink is still in the TblQCFiles table.
This causes the code to stop running and give me the error -2147024893

How can i get the code to check that the files still exist before trying to add them to my email ?

Problem is if the images are not in this folder, the code stops running.


Code:
       If Nz(DCount("*", "tblQCFiles", "Job_ID=" & Forms!Frmmain.tbJobID), 0) > 0 Then
            Set Index = CurrentDb.OpenRecordset("SELECT * FROM tblQCFiles WHERE Job_ID=" & Forms!Frmmain.tbJobID & " ORDER BY Date_Added;")
            If Not Index.EOF Then
                Index.MoveFirst
                While Not Index.EOF
                    i = i + 1
                    ReDim Preserve AttArray(i)
                    AttArray(i - 1) = Nz(Index("File_Location"), "")
                    Index.MoveNext
                Wend
            End If
            Index.Close
            Set Index = Nothing

    End If
 

tucker61

Registered User.
Local time
Yesterday, 18:11
Joined
Jan 13, 2008
Messages
217
thanks, can you help in where to call this statement in the above code ?
 

Gasman

Enthusiastic Amateur
Local time
Today, 02:11
Joined
Sep 21, 2011
Messages
7,495
Within your recordset loop?
Test if it exists and only if it does then add to your array.

BTW Index is a terrible name for a recordset :)
 

Users who are viewing this thread

Top Bottom