Bonjour à tous,
Je souhaite effectuer une exportation vers excel d'un ensemble de données. Voici mon code :
sngPrix est un prix donc un nombre à virgule (ex : 80,24) . Lorsque le fichier excel s'ouvre, le prix est divisé en 2 colonnes une première (Expr1003) avec la valeur 80 puis une seconde colonne (Prix) avec la valeur 24.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 Dim strCodeClient As String Dim strCollection As String Dim strNomArticle As String Dim sngPrix As Single Dim strNomFichier As String strCodeClient = Me.txtSaisieCodeClient.Value strCollection = Me.cboSaisieCollection.Value strNomArticle = Me.cboSaisieNomArticle.Value sngPrix = Me.txtSaisiePrix.Value strSQL = "SELECT tblArticles.CodeClient, tblArticles.Reference AS ReferenceArticle, " & strCollection & " AS Collection, " & sngPrix & " As Prix FROM tblArticles" strFiltre = " WHERE ((tblArticles.CodeClient)='" & strCodeClient & "') AND ((tblArticles.NomArticle)='" & strNomArticle & "')" MsgBox strSQL & strFiltre CurrentDb.QueryDefs("qrySQL").SQL = strSQL & strFiltre strNomFichier = "C:\test.xlsx" DoCmd.TransferSpreadsheet acExport, , "qrySQL", strNomFichier, True Shell "Excel.exe " & Chr(34) & strNomFichier & Chr(34)
Il doit s'agir d'une petite erreur de syntaxe mais je n'arrive pas à la trouver...
Merci pour votre aide,
Anthony
Partager