Hello,
currently using the function below to attach a word document to a record.
If a document already exist with same name it triggers the error number 3820
is there a way to loop all the attached documents in the record and find there name?
This way I could handle any potential naming conflict before it gets to the function and remove the "on error"
currently using the function below to attach a word document to a record.
If a document already exist with same name it triggers the error number 3820
Code:
Public Sub loadAttachFromFile(strPath As String, rsAll As DAO.Recordset, attachmentFieldName As String)
Dim rsAtt As DAO.Recordset
On Error Resume Next
Set rsAtt = rsAll.Fields(attachmentFieldName).Value
rsAll.Edit
rsAtt.AddNew
rsAtt.Fields("FileData").LoadFromFile (strPath)
rsAtt.Update
rsAll.Update
If Err.Number = 3820 Then
On Error GoTo 0
MsgBox "Parent letter already exists", vbOKOnly + vbInformation, "Letter Name Confilct"
End If
End Sub
is there a way to loop all the attached documents in the record and find there name?
This way I could handle any potential naming conflict before it gets to the function and remove the "on error"