当我使用记录集从表中读取时,一切正常,recordcount 函数显示正确的数量,但是当我使用这个简单的查询或任何查询时,我总是得到 1 作为记录计数。
这是什么工作
Option Compare Database
Option Explicit
Public Sub LoadQ2()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("test")'test is the name of my table which contains 13 rows
With rs
Debug.Print .RecordCount
.Close
End With
Set db = Nothing
Set rs = Nothing
End Sub
这是什么不起作用
Option Compare Database
Option Explicit
Public Sub LoadQ2()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT test.number_id FROM test"
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)
With rs
Debug.Print .RecordCount
.Close
End With
Set db = Nothing
Set rs = Nothing
End Sub
我应该用两个记录数得到相同的结果吧?另外我想看看我在调试记录集中的行是否可以在调试窗口中打印记录集的内容?