我正在寻找一种创建内存数据表表单的方法。我喜欢使用断开连接的记录集的想法。但在将断开连接的记录集重新分配给表单后,我遇到了应用程序崩溃的问题。在 stackoverflow 上,我受到了HK1 先生的一篇帖子的启发,他在帖子中写道:
如果您从表中获取记录集(即使它是空表)然后断开连接,则可以解决此问题。
但怎么做呢?对于 DAO.Recordset,我收到错误:此类型的对象不支持操作。我尝试了所有类型的记录集,但没有帮助:
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
对于 ADODB.Recordset,我不知道如何从本机本地或链接的 MS ACCESS 表获取它。请帮忙!