pour l'instant j'ai trouvé comme solution d'importer une table correspondant au fichier excel.
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Import", chemin, True
donc mon fichier est importer dans la table... 'Import' ^^
cette table possède les champs code client, libellé du produit et l'intitulé du mois.
ensuite je fais un UPDATE de ma table Biblio avec cette nouvelle table, ce qui à pour effet d'inserer (ou d'écraser) les données présente dans la table biblio, au champ du mois correspondant a celui de la table Import.
enfin je supprime la table 'Import' en faisant un DROP TABLE.
je trouve cette solution un peu bancale...
voici donc le code de ma fonction :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Private Sub importation()
Dim chemin As String
chemin = "C:\Documents and Settings\moi\Bureau\importclient.xls"
Annee = Me.lstImportChxAn.Value
Me.RecupMois.RowSource = "SELECT code FROM Mois where libelle like '" & Me.lstImportChxMois.Value & "' "
Mois = Me.RecupMois.ItemData(0)
libmois = Annee & "/" & Mois
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Import", chemin, True
DoCmd.RunSQL ("UPDATE Biblio INNER JOIN Import ON (Biblio.Pdt = Import.Pdt) AND (Biblio.Coclico = Import.Coclico) SET Biblio.[" & libmois & "] = [Import].[" & libmois & "];")
DoCmd.RunSQL ("DROP TABLE Import;")
MsgBox "L'importation s'est terminée avec succès !", vbInformation, "Importation terminée"
End Sub |
Partager