Topics Search

ADO.RecordSet.RecordCount

ADO.RecordSet.RecordCount
Views: 1
I can walk the recordset and see each of the values in field "PDPCOL" with debug.print

However, the line "intColCount = rst.RecordCount" always returns a value of "-1", or false. I need to know how many records are returned.
Sponsored Links:

More topics

 

MS Access 2007: ADO Recordset Filter returns 0 records

Preview
I have spent several hours on a problem with ADO recordset trying to filter records. I always get 0 records.

Sample project: [LINK]

To run in Immediate Window:
?fncRO_KontrolaSouctu_ZU(17)

Debug.Print:

rS1.RecordCount = 4
rS2.RecordCount = 13

rS2.Filter = (ParPol like '555?????') rs2.RecordCount = 0
rS2.Filter = (ParPol like '5556????') rs2.RecordCount = 0
rS2.Filter = (ParPol like '55221???') rs2.RecordCount = 0
rS2.Filter = (ParPol like '555611??') rs2.RecordCount = 0

rs2 must be read/write. I'd like to stay with late binding.
 

Cursors in MS Access and ADO

Preview
In multi-user, multi-tier distributed application scenarios where one has to provide the most current data possible, keeping the network traffic low can be challenging. The idea of using cursors becomes very appealing by offering different ways of showing the data. This tutorial, the third in a series covering MS Access and ADO, looks at cursors. TOC: Cursors in MS Access and ADO; ADO Cursors; The Recordset's RecordCount, AbsolutePosition, BOF and EOF properties; CursorType changed to adOpenForwardOnly.
 

RecordSet RecordCount returning -1

Preview
I am using the following to create a connection to an Access DB.

[code]

Unfortunately, when I try to use the RecordCount property it always returns -1. I have tried to Google this and everywhere keeps telling me why it happens but offers no suggestion to fix it. For example from [LINK]:

Note: This property will return -1 for a forward-only cursor; the actual count for a static or keyset cursor; and -1 or the actual count for a dynamic cursor.

Note: The Recordset object must be open when calling this property. If this property is not supported it will return -1.
rs.Supports(adBookmark) is returning True and I am still getting -1. It returns all the records without a problem, but any reference to RecordCount at any point gives me this -1 value. As I understand it from googling, DAO recordsets do this if you don't go to EOF first. but ADO recordsets shouldn't do this normally.
 

Testing Recordset for Records

Preview
I have long used .recordcount to test a recordset for records before doing some sort of processing.

For example:

If rst.recordcount = 0 then
exit sub
else
Do some process
End If

This usually does the trick but I am wondering.is there another method I might try to see if a recordset contains records
 

Testing Recordset for Records

Preview
I have long used .recordcount to test a recordset for records before doing some sort of processing.

For example:

If rst.recordcount = 0 then
exit sub
else
Do some process
End If

is there another method I might try to see if a recordset contains records?
 

DAO.Recordset Vs ADODB.Recordset Vs Recordset

Preview
So I know that there are two types of libraries for retrieving recordsets, either DAO or ADO.
I read somewhere that if you are using DAO, you should use DAO.recordset instead of just "recordset" to make sure it run properly.
E.g.
Dim rs As DAO.Recordset
instead of
Dim rs As Recordset

but if the default is DAO anyways (I think), would it really cause any problems. (I'm using Access 2003)

So now, which is better DAO or ADO if I'm only using a recordset to update a single field of a record from a table that may contain hundreds of records.

Which is better in general? What exceptions are there? What do other people use
 

How to: Bind a Form to an ADO Recordset

Preview
Describes how to set a form's Recordset property to an open ADO Recordset object.
 

ADO Recordset Literature

Preview
Can anyone provide a link or two to some good ADO Recordset information? I have a feeling I am going to be using them more and I am an amateur at best
 

Using the Recordset with MS Access and ADO

Preview
A Connection object may give you access to the database, but that's only half the equation; the Recordset object gives you access to the data. Keep reading to learn more about the Recordset. TOC: Using the Recordset with MS Access and ADO; The Recordset Object, Properties, Methods and events; Write code to Open ADODB connection, Recordset and close open objects; Review recordset properties using code.
 

SQL works in query but not VBA

Preview
For over a year now I have used the following sql statement to open an ADO recordset in Access 2007 VBA for a monthly process we have. This month the recordset showed no recordsto be processed. I copied the statement into a new query and the query returned over 30 records.

I found that if I try to re-create the query completely using code and opening the recordset directly from a table, the recordset would give the correct number of records.

I've also checked the recent critical updates installed and can't find one that may have changed vba's ability to open a recordset from a query. I have hundreds of ADO recordsets opened on queries throughout my database and don't want to have to re-write all the SQL statements so any help is greatly appreciated.

sql = "SELECT * FROM << myQuery >> WHERE File_Name = '" & [File] & "' ORDER BY Acct1;"
rsTemp.Open sql, cnMe, adOpenStatic, adLockOptimistic
If rsTemp.RecordCount > 0 Then
<< process data >&gt