0

I am reading excel data using Select query in VBA but query is not reading the line items where Column "TEILENUMMER" is alphanumeric like 61615A27D68 but able to read the line items where "TEILENUMMER" is numeric like 61627356223.

Dim objConn As Object

Dim objRecordSet As Object

Dim objRecCmd As Object


Set objConn = CreateObject("ADODB.Connection")

Set objRecCmd = CreateObject("ADODB.Command")

Set objRecCmd_Update = CreateObject("ADODB.Command")

strFolderPath = "/testexcel"


strquery = "Select [BUNO],[RECHNR],[RECHDAT] from [Tabelle1$] where ([RECHNR] ='" & StrInvoiceNumber & "' AND ([TEILENUMMER] Is Not Null) AND ([TEILENUMMER] <> 0))")


objConn.Open ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strFolderPath & ";Extended Properties=""Excel 12.0;IMEX=1""")

'Set objConn.Open = objConn.Execute(Source, Options:=Options)

Set objRecordSet = CreateObject("ADODB.Recordset")



objRecordSet.CursorLocation = adUseClient


objRecCmd.ActiveConnection = objConn


objRecCmd.CommandText = strQuery



objRecordSet.Open objRecCmd, , adOpenKeyset, adLockOptimistic


                 If Not objRecordSet.BOF And Not objRecordSet.EOF Then

                    objRecordSet.MoveFirst

                 End IF
Brian M Stafford
  • 8,483
  • 2
  • 16
  • 25

0 Answers0