[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Getting Run time error 2115 when setting form recordset

Posted on 2012-04-10
3
Medium Priority
?
583 Views
Last Modified: 2012-04-16
Hello,

I am trying to set the recordset of a form via a stored procedure but I keep getting a '2115' error Method 'recordset of object" failed on the following line "Set Me.Recordset = rst".  The code works fine until that point.  

Public Sub ApplyReviewFilter()

Dim objCmd As ADODB.Command
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim prm As ADODB.Parameter


Dim strReview As String

strReview = Nz(Me.cmbSelectReview, "")


Set cnn = New ADODB.Connection

cnn.ConnectionString = cStrOLEDBConnectionString
cnn.Open

Set objCmd = New ADODB.Command
cnn.CursorLocation = adUseClient

Set rst = New ADODB.Recordset

With objCmd
    .ActiveConnection = cnn
    .CommandText = "dbo.spRetrieveByReview"
    .CommandType = adCmdStoredProc
    .CommandTimeout = 3600
    Set prm = .CreateParameter("pReview", adVarChar, adParamInput, 500, strReview)
    .Parameters.Append prm
End With
   
    With rst
        .ActiveConnection = cnn
        .CursorType = adOpenStatic
    End With  
   
    Set rst = objCmd.Execute
    Set Me.Recordset = rst
    objCmd.Parameters.Delete ("pReview")  
 
    rst.Close
    cnn.Close
    Set rst = Nothing
    Set cnn = Nothing
    Set objCmd = Nothing
   
End Sub
0
Comment
Question by:chtullu135
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 40

Expert Comment

by:als315
ID: 37831215
You should run this code from opened form (in this case you will have Me). May be in On Open event.
http://support.microsoft.com/kb/281998/en-us
0
 

Accepted Solution

by:
chtullu135 earned 0 total points
ID: 37832786
I found the problem.  I was inadvently calling the procedure from the before update event of a command button instead of the afterupdate event. It was a dumb mistake on my part.
0
 

Author Closing Comment

by:chtullu135
ID: 37850305
I found the solution on my own.  It was caused by calling the procedure from the wrong event of the command button
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question