在Access VBA中,当将记录集作为快照打开时,是否会使只读选项变得多余?乍一看,这似乎是对的,因为快照本质上已经是只读的,但是似乎总是有一些警告。

例:

Dim acc      as Access.Application
Dim db       as DAO.Database
Dim rs       as DAO.Recordset
Dim sqltext  as String

sqltext = "SELECT * FROM SOMESOURCE"

Set rs = db.OpenRecordset(sqltext, dbOpenSnapshot, dbReadOnly)

'Because the type is dbOpenSnapshot, does dbReadOnly become redundant?

最佳答案

检查记录集的Updatable属性。此打印错误。

sqltext = "SELECT * FROM TABLE_01"
Set db = CurrentDb
Set rs = db.OpenRecordset(sqltext, dbOpenSnapshot)
Debug.Print rs.Updatable


因此,是的,dbOpenSnapshot作为记录集类型选项为您提供了一个只读记录集。

10-05 21:02