During a recent project, I encountered an intriguing quirk in Microsoft Access that’s worth sharing. This peculiar behavior occurs when mixing ADODB and DAO recordsets in form events, leading to unexpected results that could easily be mistaken for database corruption.
The Setup
I initially created a form with a dynamically built ADODB recordset in the Form_Open event:
Private Sub Form_Open(Cancel As Integer)
Dim rstVirtual As Object
Set rstVirtual = CreateObject("ADODB.Recordset")
With rstVirtual
.Fields.Append "ItemId", 20
.Fields.Append "ItemDescription", 200, 50
.CursorType = 3 ' adOpenStatic
.CursorLocation = 3 ' adUseClient
.LockType = 3 ' adLockOptimistic
.Open
End With
'...
Set Me.Recordset = rstVirtual
End Sub
Continue reading →