Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to Count Records? (A2k (9.0.3821) SR-1)

    How to Count Records?

    A2k (9.0.3821) SR-1

    I have to following code in a Form:

    strSQL = "SELECT * FROM tblDentists WHERE lngType = " & lngType
    Me.RecordSource = strSQL

    How do I store count of records in a variable?

    Thanks, John

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to Count Records? (A2k (9.0.3821) SR-1)

    Me.Recordset.RecordCount
    If you using ADO, the help file say
    <hr>Use the RecordCount property to find out how many records are in a Recordset object. The property returns -1 when ADO cannot determine the number of records or if the provider or cursor type does not support RecordCount. Reading the RecordCount property on a closed Recordset causes an error.<hr>

    You could always use a new recordset and use
    "SELECT COUNT(*) as NumberOfRecords FROM tblDentists WHERE lngType = " & lngType
    Francois

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: How to Count Records? (A2k (9.0.3821) SR-1)

    If you're using DAO, you can do this:

    Dim rst As Recordset
    Dim lngCount as Long

    Set rst = Me.RecordsetClone
    rst.MoveLast

    lngCount = rst.RecordCount
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •