U
Unnur U
Dear support,
I must read Excel data into a ADO recordset in Access.
All works fine if all IDs are numeric or string. If IDs
are sometimes string and sometimes numeric does ADO
returns Null value for the IDs which are not of same
datatype as the first value.
Following is very simple example of the problem.
The Excel file Test.xls is as following (a header and 4
lines of data):
ID Descript. Unit Price
1 ProA m 123
A ProB ft 345
2 ProC kg 567
B ProD mm 789
My VBA code is as following:
Dim cnnExcel As New ADODB.Connection
With cnnExcel
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Extended Properties").Value = "Excel 8.0"
.Open "C:\Test.xls"
End With
Dim rsExcel As New ADODB.Recordset
rsExcel.Open "Select * from [Sheet1$]", cnnExcel,
adOpenStatic
Do Until rsExcel.EOF
Debug.Print rsExcel.Fields(0).Value
Debug.Print rsExcel.Fields(1).Value
Debug.Print rsExcel.Fields(2).Value
Debug.Print rsExcel.Fields(3).Value
rsExcel.MoveNext
Loop
Do you know how I can solve this?
Unnur
I must read Excel data into a ADO recordset in Access.
All works fine if all IDs are numeric or string. If IDs
are sometimes string and sometimes numeric does ADO
returns Null value for the IDs which are not of same
datatype as the first value.
Following is very simple example of the problem.
The Excel file Test.xls is as following (a header and 4
lines of data):
ID Descript. Unit Price
1 ProA m 123
A ProB ft 345
2 ProC kg 567
B ProD mm 789
My VBA code is as following:
Dim cnnExcel As New ADODB.Connection
With cnnExcel
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Extended Properties").Value = "Excel 8.0"
.Open "C:\Test.xls"
End With
Dim rsExcel As New ADODB.Recordset
rsExcel.Open "Select * from [Sheet1$]", cnnExcel,
adOpenStatic
Do Until rsExcel.EOF
Debug.Print rsExcel.Fields(0).Value
Debug.Print rsExcel.Fields(1).Value
Debug.Print rsExcel.Fields(2).Value
Debug.Print rsExcel.Fields(3).Value
rsExcel.MoveNext
Loop
Do you know how I can solve this?
Unnur