Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 17th, 2005, 07:38 AM
Authorized User
 
Join Date: Jul 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default Opening recordset based on stored procedure

I have a query in my Access project called qryFName that I want to use as the source for a recordset. It is a very simple query right now, because I wanted to make sure this would work. When I run this code, I get an empty recordset back. I appreciate any insights into what is happening.

Here is the code I am using:
Code:
Dim rs As New ADODB.Recordset
Dim cnn As New ADODB.Connection
Dim rsCom As New ADODB.Command

cnn = CurrentProject.Connection
cnn.Open

rsCom.CommandText = "qryFName"
rsCom.CommandType = adCmdStoredProc
rsCom.ActiveConnection = cnn
Set rs = rsCom.Execute
If rs.EOF And rs.BOF Then
    MsgBox ("No Records Dude")
End If
rs.close
cnn.Close
Set rsCom = Nothing
 
Old March 17th, 2005, 05:07 PM
ru1 ru1 is offline
Authorized User
 
Join Date: Feb 2005
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this one out and see if it helps:

Dim db As Database
Dim rec As Recordset
Dim stDocName As String

Set db = CurrentDb()

Set rec = db.OpenRecordset("qryFName", dbOpenDynaset)
If Not rec.EOF Then
    msgbox("Records Dude")
Else
    msgbox("No Records Dude")
End If

 
Old March 17th, 2005, 10:09 PM
Authorized User
 
Join Date: Jul 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

DAO handles this no problem, but I am trying to do all of my new projects in ADO. Is this a weakness in ADO, or am I missing something in my understanding?

Thanks for the idea.

misterqj





Similar Threads
Thread Thread Starter Forum Replies Last Post
Can i return a recordset in a Stored procedure chiefouko VB Databases Basics 6 December 12th, 2006 03:34 AM
How to get # of recs without opening recordset amjad_mahmood Excel VBA 0 August 9th, 2005 05:49 AM
Opening a Form based on two Values mikericc Access 1 May 10th, 2004 03:52 PM
Opening A RecordSet Onyx2ir Access VBA 6 December 31st, 2003 12:46 AM
Can i return a recordset in a Stored procedure chiefouko SQL Server 2000 1 June 23rd, 2003 06:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.