[BDD] fichier lié à une bdd
Bonjour,
J'ai un fichier excel lié à une bdd access qui lance une requete et récupère les données de la requete dans une feuille.
Seulement, je trouve cela TRES LENT.
Voici le code que j'utilise:
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 32 33
| Dim dbAccess As Access.Application
Dim table As Recordset
Dim maRequete As String
Dim fichierRetoursLocal As Workbook
Dim fichierRetoursGlobal As Workbook
Dim ligne As Integer
Set dbAccess = New Access.Application
dbAccess.Visible = False
dbAccess.OpenCurrentDatabase (TextBox35.Value)
ligne = 2
maRequete = TextBox38.Value
Set fichierRetoursLocal = Workbooks.Open(TextBox36.Value)
Set fichierRetoursGlobal = Workbooks.Open(TextBox37.Value)
Set table = dbAccess.CurrentDb.OpenRecordset(maRequete)
'vider le fichier local
fichierRetoursLocal.Sheets(1).Range("A2:F65535").Clear
'remplir avec les données de la requete
Do While Not table.EOF
With fichierRetoursLocal.Sheets(1)
.Range("A" & ligne).Value = table.Fields(0).Value
.Range("B" & ligne).Value = table.Fields(1).Value
.Range("C" & ligne).Value = table.Fields(2).Value
.Range("D" & ligne).Value = table.Fields(3).Value
.Range("E" & ligne).Value = table.Fields(4).Value
.Range("F" & ligne).Value = table.Fields(5).Value
End With
table.MoveNext
ligne = ligne + 1
Loop |
Savez-vous s'il y a une autre méthode plus rapide ?
(le résultat de la requete comporte environ 40000 lignes)
edit: je viens de chronométrer: ça prend environ 30 à 40secondes par tuple...8O
Merci