参照設定に「Microsoft Active Data Object 2.0 Library」追加
また、デフォルトが以下なので、変更する。
rs.CursorLocation = adUseServer(デフォルト)
↓↓↓↓↓↓変更 ↓↓↓↓↓↓
rs.CursorLocation = adUseClient
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient <— これを指定
※DAOのrecordcountで件数が取れないときはこちらを参照
または、コネクションでCursorLocationをクライアントサイドカーソルに変更して、RecordCountを取得する
dim connect, rs, count
Set connect = CreateObject("ADODB.Connection")
connect.Open "xxx"
connect.CursorLocation = 3 ' クライアントサイドカーソルに変更
Set rs = CreateObject("ADODB.Recordset")
rs.Open "SELECT * FROM HOGE(NOLOCK)", connect
If rs.eof Then
' 0件の場合の処理
End If
' RecordCountの取得
count = rs.RecordCount
rs.Close
Set rs = Nothing

