レコードセットを使用してテーブルから読み取ると、すべてが正常に機能し、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
両方のrecordcountで同じ結果が得られるはずですよね?? また、デバッグ ウィンドウでレコードセットの内容を印刷することは可能ですか?