I am trying to pass an array list of distinct values to a query. I am new to
VB and am really having difficulty with this problem. Below is code taken from the Access 2003 VBA Programmer's Reference but it fails when trying to populate the array (using distinct query to populate values). Can someone correct my error? I need to use the parameters as input to another query that will output the distinct account records to an excel file.
Sub test()
Dim parm As ADODB.Parameter
Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset
Set parm = New ADODB.Parameter
Set cmd = New ADODB.Command
Set rs = New ADODB.Recordset
With cmd
.ActiveConnection = CurrentProject.Connection
.CommandText = "qryCustom"
.CommandType = adCmdTable
.Parameters.Refresh
.Parameters("acct()") = "qryDistinctAcct"
Set rs = .Execute
End With
rs.Close
Set rs = Nothing
Set cmd = Nothing
End Sub