VBAからselect into #table できることもある

Dim Parm As Long
Param= **
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
cn.ConnectionString = “接続文字列”
cn.Open

cn.Execute “drop table if exists #table”
cn.Execute “select * into #table from Other where column=” & Param
cn.execute “update #table set ・・・”
以下略

シンプルにこれだけならば#テーブルは作成されますが

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
cn.ConnectionString = “接続文字列”
Set rs = New ADODB.Recordset
cn.Open

rs.open “SQL文”,cn,・・・
以下略

cn.Execute “drop table if exists #table”
cn.Execute “select * into #table from Other where column=” & Param
cn.execute “update #table set ・・・”
以下略

と複雑になるとオブジェクトは無効ですとエラーです。

なぜかはわかりませんがレコードセットが必要ならprivate sub を別に作って
callにしたらうまくいきます。