将ADODB.Recordset
对象传递给子例程时遇到类型不匹配错误。请参阅下面的代码块。
Sub CreateRS()
Dim oCONN As ADODB.Connection
Dim oRS As ADODB.Recordset
Dim strSQL As String
Dim strConn As String
strConn = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & ActiveWorkbook.FullName & ";" & _
"Extended Properties=""Excel 12.0;HDR=Yes;"";"
Set oCONN = New ADODB.Connection
oCONN.Open strConn
strSQL = "SELECT * FROM mytable"
Set oRS = New ADODB.Recordset
oRS.Open strSQL, oCONN
' type mismatch error for the next statement
ProcessRS (oRS)
End Sub
Sub ProcessRS(ByRef RS As ADODB.Recordset)
....
End Sub
进行了相当多的搜索,但未找到正确的答案。任何人都可以指出在这里使用什么是正确的语法?谢谢!