here is an example that works
------------------------------
Dim cmd As New ADODB.Command
Dim rs as New ADODB.Recordset
Dim sQueryName as String
Dim lParam1 as long
Dim sParam2 as String
lParam1 = 100
sParam2 = "Miller"
sQueryName = "QueryInAccess97"
With cmd
Set .ActiveConnection = con 'con is an active ADODB.Connection
.CommandText = sQueryName
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter("Param1", adInteger, adParamInput, ,
lParam1)
.Parameters.Append .CreateParameter("Param2", adVarChar, adParamInput, len(sParam2),
sParam2)
End With
rs.Open cmd, , adOpenKeyset, adLockOptimistic
DEFINITION of the query "QueryInAccess97":
PARAMETERS Param1 long, Param2 text;
SELECT FROM Table1 WHERE Table1.CustomerID =[Param1] AND Table1.Name = [Param2]
1) You must create the parameters in the same order as they are defined in
your query.(Same type and name aswell of course)
2) if you use a parameter of type 'adVarchar' its length must be passed aswell.