Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    USA
    Posts
    385
    Thanks
    0
    Thanked 0 Times in 0 Posts

    RecordCount (Access 2003)

    When I try to get a record count on a query, it returns either 0 or 1 even when I know the number of records returned is greater than 1.

    The code I am using is

    Set doubleRS = double.DB.OpenRecordset("qsFourFirst_NotActive")
    me.lblFourFirst_Count.Caption = doubleRS.RecordCount.

    I am using DAO database and recordset objects.

    If I use a doubleRS.MoveLast before the record count statement, that returns the correct if there are records returned, but an error if there are no records returned.

    Is this the proper functiong of this object? Iam I doing something incorrect?


    Thanks
    Richard

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 18 Times in 18 Posts

    Re: RecordCount (Access 2003)

    You can use code like this:

    Set doubleRS = ...
    If Not doubleRS.EOF Then
    doubleRS.MoveLast
    End If
    Me.lblFourFirst_Count.Caption = doubleRS.RecordCount

    The code checks whether there are any records before trying to move to the last record.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    USA
    Posts
    385
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: RecordCount (Access 2003)

    That did the trick

    Thanks
    Richard

Posting Permissions

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