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 34 35 36 37 38 39 40
| Private Sub btn_AjoutPhoto_Click()
Dim path As String
Dim searchstr As String
Dim filecount As Long
Dim dircount As Long
Dim sub_dir As Boolean
Dim sql As String
Me.txt_SelectFolder.Value = SelectFolder("Sélectionnez un répertoire :", Me.hwnd)
MsgBox "Attention, vous vous apprêtez à ajouter tous les fichiers images présents " & (Chr(13)) & "dans le dossier " & Me.txt_SelectFolder & (Chr(13)) & (Chr(10)) & (Chr(10)) & "Voulez-vous continuer ?", vbQuestion + vbYesNo, "Ajout de photos"
If vbNo = True Then
DoCmd.CancelEvent
End If
path = Me.txt_SelectFolder.Value
searchstr = "*.jpg"
sub_dir = True
'on vide la table
DoCmd.SetWarnings False
CurrentDb.Execute ("DELETE * FROM ListageFichier")
DoCmd.SetWarnings True
Call FindFilesAPI(path, searchstr, filecount, dircount, sub_dir)
sql = "INSERT INTO Photos " & "SELECT AdressePhoto " & "FROM [ListageFichier];"
DoCmd.RunSQL (sql)
MsgBox "Les photos ont été ajoutées", vbOKOnly, "Ajout terminé"
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frm_PhotosSaisie"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub |
Partager