Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

number of records after a recordset.FindFirst 1

Status
Not open for further replies.

Jedi420

Programmer
Jun 21, 2002
184
US
Hello,

I need to know if there is a way to find out how many records there are when you perform a FindFirst on a recordset object. I tried using the recordcount property, but that gives me the number of records for the whole recordset ... I just need to know how many records there are according to the specific criteria that I apply to it ... For instance:

Code:
     Dim db As Database
     Dim rst As Recordset
     Dim criteria As String
     
     criteria = "[projID] = " & txtID.Value
     
     Set db = CurrentDb    
     Set rst = db.OpenRecordset("MBA_Mgmt_Assignments", dbOpenDynaset)

     rst.FindFirst criteria
        
     If rst.NoMatch = False Then
         RIGHT HERE IS WHERE I NEED TO KNOW HOW MANY 
         RECORDS MATCH MY CRITERIA
     end if

Any suggestions or advice would be greatly appreciated. Thanks (^_^)

-Jedi420
 
Findfirst is a bookmark positioning method; it moves to the first instance where criteria are satisfied.

You need to use a match or Where method. I believe there is a count by criteria method as well... is it Dcount?..I'll have to have a look.
Later,
John
 
Hey, that's it! Thanks a bunch (^_^)

-Jedi420
 
Actually, the more generic approach wouuld be to use COUNT() with the criteria. Ther is no need (or any real use) for hte NoMatch. Further, hte use of NoMatch in itself implies either the use of Ms. A. ver '97 (or earlier) which in turn implies the use of DAO. recordsets. NoMatch is not available with ADO.




MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top