
CODE
Private Sub Form_Open(Cancel As Integer)
Dim MyName As String
Dim MyPath As String
Dim Ligne As Integer
Dim Ligne2 As Integer
Dim cmd As String
DoCmd.RunCommand acCmdDocMaximize
Me.t_Theme.Visible = False
Me.Étiquette23.Visible = False
DoCmd.Close acForm, "Menu_Visu"
Me.C_Consult.Visible = False
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * from Tb_Fichier"
Ligne = 0
MyPath = "C:\Prospect-2000\Import\"
MyName = Dir(MyPath, vbDirectory)
Do While MyName <> ""
If MyName <> "." And MyName <> ".." And Right(MyName, 7) <> "air.xls" And Right(MyName, 4) = ".xls" And Left(MyName, 7) = "Export_" Then
Ligne = Ligne + 1
cmd = "insert into Tb_Fichier (Fichier, Chemin, Cle, Nombre)" _
& "VALUES ('" & MyName & "', '" & MyPath & "', Mid('" & MyName & "', 8, Len('" & MyName & "') - 11), " & Ligne & ");"
DoCmd.RunSQL cmd
End If
If MyName <> "." And MyName <> ".." And Right(MyName, 10) = "Impair.xls" And Right(MyName, 4) = ".xls" And Left(MyName, 7) = "Export_" Then
Ligne = Ligne + 1
cmd = "insert into Tb_Fichier (Fichier, Chemin, Cle, Nombre)" _
& "VALUES ('" & MyName & "', '" & MyPath & "', Mid('" & MyName & "', 8, Len('" & MyName & "') - 17), " & Ligne & ");"
DoCmd.RunSQL cmd
Else
If MyName <> "." And MyName <> ".." And Right(MyName, 8) = "pair.xls" And Right(MyName, 4) = ".xls" And Left(MyName, 7) = "Export_" Then
Ligne = Ligne + 1
cmd = "insert into Tb_Fichier (Fichier, Chemin, Cle, Nombre)" _
& "VALUES ('" & MyName & "', '" & MyPath & "', Mid('" & MyName & "', 8, Len('" & MyName & "') - 15), " & Ligne & ");"
DoCmd.RunSQL cmd
End If
End If
MyName = Dir
Loop
cmd = "UPDATE Tb_Fichier INNER JOIN Choix ON Tb_Fichier.Cle = Choix.Clé SET Tb_Fichier.Ville = [Choix]![VILLE], Tb_Fichier.Rue = [Choix]![Rue ou voie];"
DoCmd.RunSQL cmd
DoCmd.SetWarnings True
Me.L_Fichier.Requery
If Ligne = 0 Then
MsgBox " Vous n'avez pas de fichier a Intégrer !!! ", vbOKOnly, "Attention !"
DoCmd.OpenForm "Menu_Gen"
DoCmd.Close acForm, "Menu_Import"
Else
Me.Nombre.Value = Ligne
DoCmd.Close acForm, "Menu_Gen"
End If
End Sub
2 - 3 mots pour expliquer ce que je voulais faire
Lister tous les fichiers du genre "Export_" + * + ".xls"
du répertoire : "C:\Prospect-2000\Import\"