I'm trying to use ArrayList as a parameter for the query, but when I use it as I do below, I get an error. However, if I replace ArrayList in the query with (335, 336, 337) the query works fine. How can I pass the array?
Thank you
Matt
[VBA]
Sub Test4()
Dim cnMTPS As ADODB.Connection
Dim cmd As ADODB.Command
Set rst = New ADODB.Recordset
Set cnMTPS = New ADODB.Connection
cnMTPS.ConnectionString = "DSN=MS Access Database;DBQ=P:\T Data\Master Data File.mdb;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"
cnMTPS.Open
Set cmd = New ADODB.Command
cmd.ActiveConnection = cnMTPS
cmd.CommandType = adCmdText
ArrayList = Array(335, 336, 337)
cmd.CommandText = "SELECT Performance.ID, Performance.Date, Performance.Return FROM `P:\T Data\Master Data File for SE`.Performance Performance WHERE (Performance.ID in (ArrayList))"
Set rst = cmd.Execute
Sheet1.Range("A2").CopyFromRecordset (rst)
'cmd.CommandText = "DROP TABLE #ID"
'cmd.Execute
cnMTPS.Close
End Sub
[/VBA]