Dim cmdPBIRecs As New ADODB.Command
cmdGetRecs.CommandText = "qrySalesReport"
Which Command object???
Darryl Kerkeslager
Power corrupts.
Absolute power corrupts absolutely.
Knowledge is power.
Demo:
www.adcritic.com/interactive/view.php?id=5927
<u7djo@hotmail.com> wrote in message
news:1109257446.504843.86970@z14g2000cwz.googlegro ups.com...[color=blue]
> I've built a query in Access and added a parameter to it called
> [CurrentPeriod]. I'm trying to load the recordset by using an ADO
> command and attaching a parameter to it but I keep getting an error
> message when trying to open the recordset (arguments are out of
> acceptable range or are in conflict with each other). I've checked the
> data types and as much as I can think of - can anyone shed any light on
> this? I'm sure I've done it before but can't find the code anywhere and
> it's driving me crazy!!!
>
> Thanks
>
> Dave
>
> --- Code ---
>
> Dim o_conn As New ADODB.Connection
> Dim rspols As New ADODB.Recordset
> Dim m_conn_str As String
> Dim i_period As Integer
> Dim parmPeriod As New ADODB.Parameter
> Dim cmdPBIRecs As New ADODB.Command
>
> m_conn_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=*****"
> o_conn.CursorLocation = adUseClient
> o_conn.ConnectionString = m_conn_str
> o_conn.Open
> i_period = CInt(InputBox("Which period are you reporting against?",
> "Reports", ""))
>
> cmdGetRecs.CommandText = "qrySalesReport"
> cmdGetRecs.CommandType = adCmdStoredProc
> cmdGetRecs.ActiveConnection = o_conn
> cmdGetRecs.Parameters.Refresh
>
> Set parmPeriod = cmdGetRecs.CreateParameter("CurrentPeriod",
> adInteger, adParamInput, , i_period)
> cmdGetRecs.Parameters.Append parmPeriod
>
> rspols.Open cmdGetRecs.Execute, o_conn, adOpenForwardOnly,
> adLockOptimistic
>[/color]