SELECT query * FROM Does not bring all the data

0

I'm doing a query from one excel file to another. Through a recordset with the method SELECT I bring the columns that I want to my base, the problem is that I have a column Date de Facture with data type DATE (04/01/2018) and other data type TEXT (04-AUG-2018) . When I run the query it only brings me the DATE type data. How do I bring all the data from that column and if possible bring them all format DATE ???

I attach the code, thanks for the help!

Sub Importer_Donnees()
Dim oConn As New ADODB.Connection
Dim rst As New ADODB.Recordset

Extension = "Tous les fichiers (*.*),*.*"
Index = 5
Titre = "Sélectionnez le fichier à importer ?"
Fichier = Application.GetOpenFilename(Extension, Index, Titre)

If Fichier = False Then
    MsgBox "Aucun fichier sélectionné !": End
Else

Range("BaseFacturation").Clear
    Workbooks.Open Filename:=Fichier
    ActiveSheet.Name = "Extraction_Facturation"
    ActiveWorkbook.Save
    ActiveWorkbook.Close
End If

a1 = "Type"
a2 = "N° de Facture"
a3 = "Date de Facture"
a4 = "Transporteur"
a5 = "Ensemble"
a6 = "Mode de tarification"
Ruta = Fichier

oConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Ruta & "';Extended Properties='Excel 12.0;HDR=Yes;IMEX=1';"
oConn.Open ConnectionString:=oConn

rst.Open "SELECT [" & a1 & "],[" & a2 & "], [" & a3 & "],[" & a4 & "],[" & a5 & "],[" & a6 & "] FROM [Extraction_Facturation$A1:BU] ", oConn, adOpenStatic, adLockReadOnly

last1 = Sheets("BaseFacturation").Cells(Sheets("BaseFacturation").Rows.Count, "A").End(xlUp).Row + 1

Sheets("BaseFacturation").Range("A" & last1).CopyFromRecordset rst

rst.Close

Last = Sheets("BaseFacturation").Cells(Sheets("BaseFacturation").Rows.Count, "A").End(xlUp).Row + 1

oConn.Close

Sheets("BaseFacturation").Range("A" & Last & ":U1048576").EntireRow.Delete

End Sub
    
asked by Juan 09.08.2018 в 12:43
source

0 answers