Please help with strange count prob.

A

Al

I am using the following code:

dim rst17Cases As Recordset,sql As String

sql = "SELECT tbl17cases.OLDPIN, tbl17cases.StartDate FROM
tbl17cases"
Set db = CurrentDb()
Set rst17Cases = db.OpenRecordset(sql)
Debug.Print rst17Cases.RecordCount

The problem is that my recordcount is always 1 even though
my table has 17 records? I used similar code in a
different place and it counts the table right. why is not
it working here. the code is behind a command button and I
am working in Access 2002. any help please
thanks
Al
 
C

Cheryl Fischer

If you will insert the following line before the "Debug.Print ..."
statement, you should get the correct record count.

rst17Cases.MoveLast

After the "Debug.Print ... " statement you can always go back to the first
record in the recordset with:

rst17Cases.MoveFirst
 
A

Andy

Al said:
I am using the following code:

Insert the following lines

dim rst17Cases As Recordset,sql As String

sql = "SELECT tbl17cases.OLDPIN, tbl17cases.StartDate FROM
tbl17cases"
Set db = CurrentDb()
Set rst17Cases = db.OpenRecordset(sql)
rst17Cases.movelast
rst17Cases.movefirst

Debug.Print rst17Cases.RecordCount

The problem is that my recordcount is always 1 even though
my table has 17 records? I used similar code in a
different place and it counts the table right. why is not
it working here. the code is behind a command button and I
am working in Access 2002. any help please
thanks

Refer to the Help menu about RecordCount

"Remarks

Use the RecordCount property to find out how many records in a Recordset or
TableDef object HAVE BEEN ACCESSED. The RecordCount property doesn't
indicate how many records are contained in a dynaset-, snapshot-, or
forward-only-type Recordset object until all records have been accessed.
Once the last record has been accessed, the RecordCount property indicates
the total number of undeleted records in the Recordset or TableDef object. "

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top