3
votes

I am working with a legacy database .mdb database that just crashes in Access 2007 when it hits lines with CurrentProject.Connection in them.

When I add the same code to brand new databases it crashes them too.

Dim rstDateFields As New adodb.Recordset
rstDateFields.Open "SELECT * FROM defDateFields ORDER BY FieldID", CurrentProject.Connection, adOpenDynamic, adLockOptimistic

References set to: VBA, MS ACCESS 12.0 object library, OLE automation, MS Ofrfice 14.0 Access db engine object

2
Have you been able to run the select statement directly?Joshua Drake
Did the application work previously with this code, or did the error occur only after updates to the code?Joshua Drake
Here are the details : granite.ab.ca/access/decompile.htmFionnuala
Is the CurrentProject.Connection open when this code executes?Joshua Drake
Take a look at How To Open ADO Connection and Recordset Objects for a checklist of what can open a connection.Joshua Drake

2 Answers

1
votes

The code you showed us was very basic ADO, so it's hard to believe the code itself is the cause of the problem. Check whether the problem is isolated to that one machine by trying the same code from another machine. If it runs without error there, mostly likely the original machine is broken somehow. Unfortunately trying to find and fix the breakage can be challenging. Good luck!

0
votes

One guess: could you make sure that your recordset is of the ADO type? Are you using an implicit declaration for your recordset, such as "Dim rs as recordset"? In this case your recordset could be of the DAO type.

And anyway we'd love to help you but you should give us some more code to understand your problem!