Count the records in a recordset (1 Viewer)

darkmastergyz

Registered User.
Local time
Yesterday, 22:35
Joined
May 7, 2006
Messages
85
How can you count the # of recordset? I tried using (rs is my recordset). Everything is populated into the rs and it works.

In order to count the # of records, now I'm using a do while not eof, and it's working, but i'm wondering, is there as alternate way to find the # of records in rs? I tried using rs.recordcount, but it didn't work. Thanks!
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 22:35
Joined
Aug 30, 2003
Messages
36,133
Try this before the recordcount line:

rs.MoveLast
 

dgkindy

Registered User.
Local time
Today, 01:35
Joined
Feb 22, 2007
Messages
34
RecordCound

When the program comes accross the recordset with more then one record it does not report the correct number of records. I took the SQL statement and put it in a query and it works. I read on the forum that I should put rs.movelast before recordcount but this causes an error so did not want to do it.

Do I need to put a rs.movelast before rs.recordcount?

Does RecordCount start at 1 or 0 like an array?

SQLLit = "SELECT tblLinkLibrary.Part_Number, tblLiterature.Literature FROM tblLinkLibrary INNER JOIN tblLiterature ON tblLinkLibrary.LinkLibraryID = tblLiterature.LinkLibraryID WHERE (((tblLinkLibrary.Part_Number)='" & rsParts!Part_Number & "'));"
Set rslit = db.OpenRecordset(SQLLit)
*Pauses program where I know there are two records*******
If rsParts!Part_Number = "3024164" Then
Temp = 1
End If
***********************************************
For X = 1 To rslit.RecordCount
rslit.MoveFirst
With rsVD
.AddNew
!Literature = rslit!Literature
!PartID = rsParts!PartID
.Update
End With
rslit.MoveNext
Next X
End If
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 22:35
Joined
Aug 30, 2003
Messages
36,133
There's some info here about the count:

http://www.mdbmakers.com/forums/showthread.php?t=5085

however, in your case, you don't really need to know it. Since you want to do something with every record, replace the For/Next with

Do While Not rslit.EOF
'your code here
Loop

By the way, I don't think you want the MoveFirst in there.
 

Users who are viewing this thread

Top Bottom