ADODB.Commandを使用してExecuteメソッドでRecordsetを作成したときに、RecordsetのRecordCountプロパティが-1になることがあります。
ADODB.CommandのExecuteメソッドではなく、ADODB.RecordsetのOpenメソッドではCursorTypeをadOpenKeysetまたはadOpenStaticにすればRecordCountプロパティでレコード数を取得することができます。
しかし、ADODB.CommandのExecuteメソッドではCursorTypeを指定できません。
そのようなときは、ADODB.CommandのActiveConnection.CursorLocationにadUseClientを指定してみてみださい。
100%という訳ではありませんが、RecordsetのRecordCountプロパティにレコード数が入ります。
Set adoCmd = New ADODB.Command
With adoCmd
.ActiveConnection = CurrentProject.Connection
.ActiveConnection.CursorLocation = adUseClient
.CommandText = "SELECT * FROM ~;"
Set rstData = .Execute(, Array(~)))
End With
MsgBox rstData.RecordCount
: