I'm looking for a way to create an in-memory datasheet form. And I like the idea of using a disconnected recordset. But I ran into the problem of the app crashing after reassigning disconnected recordset to the form. On stackoverflow, I was prompted by a post by Mr. HK1, where he wrote the following:
If you obtain the recordset from a table (even if it's an empty table) and then disconnect you can work around this problem.
But how to do it? In the case of DAO.Recordset I get the error: Operation is not supported for this type of object. I tried all types of recordset but it didn't help:
Sub testDynaset()
Dim rs As dao.Recordset
Set rs = CurrentDb.OpenRecordset("MyLocalTable", dbOpenDynaset)
rs.Connection.Close ' << error: Operation is not supported for this type of object
End Sub
Sub testForwardOnly()
Dim rs As dao.Recordset
Set rs = CurrentDb.OpenRecordset("MyLocalTable", dbOpenForwardOnly)
rs.Connection.Close ' << error: Operation is not supported for this type of object
End Sub
Sub testOpenSnapshot()
Dim rs As dao.Recordset
Set rs = CurrentDb.OpenRecordset("MyLocalTable", dbOpenSnapshot)
rs.Connection.Close ' << error: Operation is not supported for this type of object
End Sub
Sub testOpenTable()
Dim rs As dao.Recordset
Set rs = CurrentDb.OpenRecordset("MyLocalTable", dbOpenTable)
rs.Connection.Close ' << error: Operation is not supported for this type of object
End Sub
In the case of ADODB.Recordset, I don't know how to get it from a native local or linked MS ACCESS table. Please, help!