I did following: A database connection over vba in excel (DAO) works both in office 356 and 2016. After setting a database password in Office 356 this db cannot be opened over DAO in Office 2016. (both same lib, Office Access 16 database engine object". So I set the password in Office 16, works now. After opening the file in Excel 356 again Excel crashes at an unexpected operation without error message. Now all other DAO connections in all files on this pc do not work anymore. (I think its just a random bug and hasn't anything to do with this password thing)
This error is actually reproducible on this pc.
Sub Test() Dim db As DAO.Database Set db = DAO.OpenDatabase(ActiveWorkbook.Path & "/test.accdb") Dim ts As DAO.Recordset Set ts = db.OpenRecordset("SELECT * FROM Tabelle1") Dim myfield As DAO.field If Not ts.EOF Then For Each myfield In ts.Fields ' crash here MsgBox myfield.Name Next End If ts.Close db.Close End Sub
At exactly this line excel stops existing. Just press F8(next line) and back to desktop. Just away. No error. ts.Fields is not nothing as you can see in image. I've restarted my system, no change. How to repair DAO database connections? Or is some problem in this code? The same files work like expected on my other pc.
EDIT: As noted correclty it is not wise to call the object "field" as Excel imports the namespace of DAO automatically. The error also occurs when naming it myfield.
EDIT2: The error found in system protocol is somehow unspecific: ACEDAO.DLL 0xc0000005
User contributions licensed under CC BY-SA 3.0