Importation d'un tableau Excel vers un tableau Access (VBA)
Bonjour à tous,
Comme l'indique le titre je souhaiterais insérer des données d'un tableau Excel vers un tableau Access existant. Cela me permettrait de mettre à jour un statut qui vérifierait si la ligne existe déjà dans mon tableau Access (ligne qui n'existe pas sur ma partie Excel) (doublon si oui et importé sinon).
Voici l'ébauche de mon code, je n'arrive pas à savoir comment passer d'Excel à Access pour la partie où je teste :
Code:
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
|
Private Sub CmdImpJtrac_Click()
Dim dialog As FileDialog
Dim fso As New Scripting.FileSystemObject
Dim Path As String
'Open a Windows window to pick a file
Set dialog = Application.FileDialog(msoFileDialogFilePicker)
With dialog
.AllowMultiSelect = False
.Show
fileJtrac = .SelectedItems.Item(1)
End With
RepJtrac.Caption = fileJtrac
Dim xls As Excel.Application
Set xls = CreateObject("Excel.Application")
xls.Workbooks.Open fileJtrac
xls.Visible = True
Dim i As Integer
i = 2
While Not IsEmpty(Cells(i, 1))
If Not IsNull(DLookup("[Statut]", "Tableau", "[Identifiant]='" & Cells(i, 1).Value & "' AND [LastUpdate]= '" & Cells(i, 14).Value & "' ")) Then
oRst.Fields("Statut").Value = "Doublon"
Else
oRst.Fields("Statut").Value = "Importé"
End If
Wend
End Sub |
Merci