I am trying to import some data from a .mbd-file into Excel. I can copy the whole database into a spreadsheet, no problem there. I can also use a statement like this
sSQL = "SELECT HOEHE " & "FROM h_datei WHERE HOEHE >= 53 "
The problem arises when using WHERE on a field that has type other than int or float. (I don't have MS Access, but MDB Plus tells me the type for text fields in my .mdb is called 'Widestring')
I get this in a MsgBox from Excel: Run-time error '-2147217913 (80040e07)': Automation error
I have been googling and tinkering for quite a while, but I am stuck. Under is my VBA code. I don't know if this has to do with the provider (Microsoft.ACE.OLEDB.12.0) but I have tried a few others. I'm also thinking about unicode, as this database is from a german surveying program.
sConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=" & _
sPath & "Oskarb04.mdb"
sSQL = "SELECT HOEHE " & "FROM h_datei WHERE PNR >= 53 "
Set rsData = New ADODB.Recordset
Debug.Print sSQL
rsData.Open sSQL, sConnect, adOpenForwardOnly, adLockReadOnly, adCmdUnknown