hi, have a procedure that needed amending and thus required another parameter. My inital VBa code to run this procedure was: - Dim rs As ADODB.Recordset
-
GetData rs, "sp_TM_GetCurrentRoleTasks", Me.cboRole
-
Set Me.cboTask.Recordset = rs
-
-
the middle line changed to:
-
GetData rs, "sp_TM_GetCurrentRoleTasks ", CStr(Me.cboRole) & ", " & CStr(Me.txtUserID)
-
-
the Get Data function which had been working fine is:
-
Public Sub GetData(ByRef rsIn As ADODB.Recordset, strProc As String, Optional strArgs As String)
-
Dim cn As ADODB.Connection
-
-
Set cn = New ADODB.Connection
-
cn.ConnectionString = "Provider=sqloledb;Data Source=IUDATA.hscni.net;Initial Catalog=USERS;Trusted_Connection=Yes"
-
cn.Open
-
-
Set rsIn = New ADODB.Recordset
-
With rsIn
-
Set .ActiveConnection = cn
-
.ActiveConnection.CommandTimeout = 60
-
.Source = strProc & " " & strArgs
-
.CursorType = adOpenDynamic
-
.LockType = adLockPessimistic
-
.CursorLocation = adUseClient
-
.Open
-
End With
-
End Sub
yet now I get an error 7965:The object you entered is not a valid recordset property on the 3 rd line:
Set Me.cboTask.Reco rdset = rs
The procedure runs fine in an SQL query window with the source so I don't understand why I'm getting the error.
UPdate: on further investigation, the problem is not with the parameters as I initially thought - but seems to be with the stored procedure returning rowcount messages - even with using NOCOUNT.
final update: the procedure has (suddenly) started working with NOCOUNT behaving as expected. I'm not sure what I've changed so it may be of little help to others. Thanks for trying.
5 1431 jimatqsi 1,273
Recognized Expert Top Contributor
h0pal0ng42,
Welcome to Bytes.
What version of Access are you using? I'm not familiar with the Recordset property of a combo box. I normally set the Rowsource property equal to the SQL code string.
Jim
zmbd 5,501
Recognized Expert Moderator Expert
So let's treat this as I would any other MS built in function by using named parameters: - Public Sub GetData(ByRef rsIn As ADODB.Recordset, strProc As String, Optional strArgs As String)
- So our origninal would be:
-
GetData _
-
rsIn := rs, _
-
strProc := "sp_TM_GetCurrentRoleTasks", _
-
strArgs := Me.cboRole
- Now you have:
-
GetData _
-
rsIn := rs, _
-
strProc := "sp_TM_GetCurrentRoleTasks", _
-
strArgs := CStr(Me.cboRole) & ", " & CStr(Me.txtUserID)
Now I find that most errors occur when the string is constructed within the function; thus change this: - Now you have:
-
Dim zstrArgs
-
-
zstrArgs = CStr(Me.cboRole) & ", " & CStr(Me.txtUserID)
-
-
GetData _
-
rsIn := rs, _
-
strProc := "sp_TM_GetCurrentRoleTasks", _
-
strArgs := zstrArgs
-
Add a debug.print after the zstrArgs and you will be able to tell if the string is being resolved correctly.
The next item is to address, where are your quotes for the string values? I would guess that Me.cboRole was returning a numeric value, now you're attempting to use a string value.
Then finally, did you do a debug.compile, I'll bet that chokes. Follow the basic troubleshooting steps as outlined:[*] > Before Posting (VBA or SQL) Code zmbd 5,501
Recognized Expert Moderator Expert
jimatqsi:
The recordset property has been around for some time now.
I haven't used it much; however, you can actually use it like we do for recordsetclone on a form to do a quick search within the control.
It will also populate the control on an open recordset; however, I've found that you have to leave the recordset open or the values disappear whereas with the rowsource, the values are queried once and stay put.
jimatqsi 1,273
Recognized Expert Top Contributor
Thanks for the tip, z, that's interesting to know. I should have passed this one by as soon as I saw ADO in use. I stick to DAO whenever possible.
Jim
zmbd 5,501
Recognized Expert Moderator Expert
you can use this with dao as well it's part of the cbo object model. (^_^)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: M Wells |
last post by:
Hi All,
I'm wondering if anyone can tell me if it's possible to search for
stored procedures by their contents?
I tend to leave very descriptive notes in stored procedures and
they're beginning to build up in number, so I'm wondering if it's
possible to search in Query Analyzer for stored procedures that
contain certain words / phrases...
|
by: serge |
last post by:
How can i delete all user stored procedures and all table triggers very fast
in
a single database?
Thank you
|
by: jrefactors |
last post by:
I want to know the differences between SQL Server 2000 stored
procedures and oracle stored procedures? Do they have different
syntax? The concept should be the same that the stored procedures
execute in the database server with better performance?
Please advise good references for Oracle stored procedures also.
thanks!!
|
by: scott |
last post by:
Hi,
Just wondering what sort of problems and advantages people have found using
stored procedures. I have an app developed in VB6 & VB.NET and our
developers are starting to re-write some of the code in stored procedures
(im advocating encryption of them). When deploying an application however
stored procedure seem to add another level of...
|
by: Tim Bolla |
last post by:
I have created ~30 stored procedures that I need to have running on a
database in order to use the application that I have developed. I am
looking for a solution so that these stored procedures can be imported
by other people with the least amount of work.
I have been exporting the stored procedures from the DB2 Development
Center to a zip...
| |
by: Kent Lewandowski |
last post by:
hi all,
Recently I wrote some stored procedures using java jdbc code
(admittedly my first stab) and then tried to implement the same within
java packages (for code reuse). I encountered problems doing this.
I wanted to implemented a generic "Helper" class like this:
/**
* Helper
|
by: Tim Marshall |
last post by:
I was following the thread "Re: Access Treeview - Is it Safe Yet?" with
interest and on reading the post describing Lauren Quantrell's
SmartTree, I've run into something I don't understand: Stored
Procedures. I thought stored pricedures were an Oracle/MS SQL Server
thing and don't know how they work with Access Jet. I've looked at some
of...
|
by: John |
last post by:
Hi
When developing vb.bet winform apps bound to sql server datasource, is it
preferable to use SELECTs or stored procedure to read and write data from/to
SQL Server? Why?
Thanks
Regards
|
by: mooreit |
last post by:
The purpose for my questions is accessing these technologies from
applications. I develop both applications and databases. Working with
Microsoft C#.NET and Microsoft SQL Server 2000 Production and 2005 Test
Environments.
What is the purpose of a view if I can just copy the vode from a view
and put it into a stored procedure?
Should I be...
|
by: mednyk |
last post by:
T-SQL Debugger Doesn't Allow Stepping Through Stored Procedures
And there is no other procedure with the same name owned by dbo or any
other users.
There is no error messages also, it just completes procedure and
returns result
server:
Microsoft SQL Server 2000 - 8.00.818 (Intel X86)
Microsoft Corporation Enterprise Edition on Windows NT...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |