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 5 1548
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
<u7***@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com... 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
Sorry - was messing round with the names - cmdPBIRecs and cmdGetRecs
are one in the same thing.
Sorry - was messing round with the names - cmdPBIRecs and cmdGetRecs
are one in the same thing.
Right, I've finally managed to dig up the piece of code I'd used
previously where I'd managed to pass a parameter in ADO to an Access
Query referencing the query as a stored procedure. The only thing I can
see that is different is that the output of the query wasn't directed
to a recordset (it's a make table). Can anyone explain why I can do one
way but not the other?
Cheers
Dave
Public Function GetPeriodRegistrations() As Integer
Dim o_conn As New ADODB.Connection
Dim cmdLoadRegs As New ADODB.Command
Dim parmPeriod As New ADODB.Parameter
Dim m_conn_str As String
m_conn_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source =
*****;"
o_conn.CursorLocation = adUseClient
o_conn.ConnectionString = m_conn_str
o_conn.Open
On Error Resume Next
o_conn.Execute ("DROP TABLE TMP_RegsPeriodReport;")
On Error GoTo Err_Proc
cmdLoadRegs.CommandText = "qryRegsPeriodReporting"
cmdLoadRegs.CommandType = adCmdStoredProc
cmdLoadRegs.ActiveConnection = o_conn
cmdLoadRegs.Parameters.Refresh
Set parmPeriod = cmdLoadRegs.CreateParameter("ReportingPeriod",
adInteger, adParamInput, , CInt(InputBox("Which period are you
currently reporting against?: ", "Reporting", "")))
GetPeriodRegistrations = parmPeriod
cmdLoadRegs.Parameters.Append parmPeriod
cmdLoadRegs.Execute
Set cmdLoadRegs = Nothing
o_conn.Close
Err_Proc:
If o_conn.State = adStateOpen Then
o_conn.Close
End If
Set o_conn = Nothing
Set cmdLoadRegs = Nothing
Set parmPeriod = Nothing
End Function
I believe this line:
rspols.Open cmdGetRecs.Execute, o_conn, [etc]
Should be:
rspols.Open cmdGetRecs, o_conn, [etc]
Darryl Kerkeslager
Power corrupts.
Absolute power corrupts absolutely.
Knowledge is power.
Demo: www.adcritic.com/interactive/view.php?id=5927 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Andreas Lauffer |
last post by:
I changed from Access97 to AccessXP and I have immense performance
problems.
Details:
- Access XP MDB with Jet 4.0 ( no ADP-Project )
- Linked Tables to SQL-Server 2000 over ODBC
I used...
|
by: dschl |
last post by:
Hi,
I'm converting an Access 2000 database to Sql Server and must be
missing something obvious.
Using the Import utility in Sql Server, the Access queries seem to get
executed and the...
|
by: John |
last post by:
Hi
New to sql server. using beta2 2005. What is the way to implement
parameterised queries? I need the queries to be updatable as these would
work as recordsets that vb.net forms will be bound...
|
by: Jerry Hull |
last post by:
I'm working with a database developed by an untrained person over
several years - and on a network that has recently been upgraded with
a new server installed and MS office upgraded from 2K (I...
|
by: shearichard |
last post by:
Hi - I've got SQL that looks like this ...
cursor =
self.MySQLDb_conn.cursor(cursorclass=MySQLdb.cursors.DictCursor)
sqlQuery = "SELECT * FROM T1 WHERE C1 = %s and C2 = %s"
sql =...
|
by: B.r.K.o.N.j.A |
last post by:
I'm using mysql 4.1 and php5.0.4. Since (AFAIK) this version of mysql
supports parameterised queries, is there a way to accomplish that using
mysql_... functions (looks like mysql client library is...
|
by: John |
last post by:
Hi
I have a parameterised query for a report like this;
PARAMETERS Event_ID Short;
SELECT DISTINCTROW Events., ...
FROM Events
WHERE (((Events.)=));
Now I am trying to run the report...
|
by: DebGuria |
last post by:
I have written a managed C++ dll. I have to use that dll from C#,
VB .NET and VB. It has got a parameterised propetyfor the very
specific requirement. For example get_Pie(float f).
When I am...
|
by: marshmallowww |
last post by:
I have an Access 2000 mde application which uses ADO and pass through
queries to communicate with SQL Server 7, 2000 or 2005.
Some of my customers, especially those with SQL Server 2005, have had...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |