1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| Function AjouterFichier(strchemin As String, inteleve As Integer) As Boolean
Dim oFld As DAO.Field2
Set oFld = .Fields("FileData")
oFld.LoadFromFile strchemin
On Error GoTo err
Dim oRst As DAO.Recordset
'Ouvre un recordset sur les fichiers de l'éleve passé en paramètre
Set oRst = CurrentDb.OpenRecordset("SELECT PIECEJOINTE FROM GA_PIECEJOINTE_D")
With oRst.Fields(0).Value
'Ajoute la pièce jointe
.AddNew
'Lit le fichier
.Fields("FileData").LoadFromFile strchemin
.Update
End With
AjouterFichier = True
fin:
Set oRst = Nothing
Exit Function
err:
'Gestion d'erreur
Select Case err.Number
Case 3024:
MsgBox "Fichier inexistant", vbCritical
Case 3820:
MsgBox "Une autre pièce-jointe de ce nom existe déjà", vbCritical
Case Else:
MsgBox "Erreur inconnue", vbCritical
End Select
Resume fin
End Function |
Partager