I have a function that gets an ADODB recordset from the contents of a worksheet using ADO, as follows:
Function WorksheetRecordset(workbookPath As String, sh
try the below for your objRecordset features and query (tested in MS Query with Excel):
With objrecordset
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.CursorType = adOpenStatic
.ActiveConnection = objconnection
.Open "Select format(`" & sheetName & "$`.value,'0.00') as [value], something FROM [" & sheetName & "$]"
End With
so, here the JET SQL format Function is forcing ADO's SQL Parser to output a string formatted as 0.00
ALso, I have set the CursorTLocation
property to adUseClient
so you won't need to use MoveLast
and MoveFirst
let us know how you get on
Philip
Unfortuately I had the same problem once before and the reason is that the ACE driver only looks at the first value in a column to decide the data type for that entire column. So, you can try to sort the data with the numeric values on top.
The "Gold Standard" way to create joined tables in Excel is with vLookup. I would suggest doing this even though it may seem a bit "amateur."
Also, it appears that setting IMEX to 1 basically forces ACE to return the text representations so that alpha-numeric values in a numeric column are not returned as null.