Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2002
    Posts
    1

    Unanswered: Determining number of selected records if any

    Hi:

    I am wondering how I can determine if a Select statement in VBA selected any records.

    Ie. Return the number of records selected to a variable.



    Thanks,


    Jason

  2. #2
    Join Date
    Nov 2002
    Posts
    150

    Re: Determining number of selected records if any

    Originally posted by jpond
    Hi:

    I am wondering how I can determine if a Select statement in VBA selected any records.

    Ie. Return the number of records selected to a variable.



    Thanks,


    Jason
    If you want the exact number of records, use something like this:

    Public Function test()
    Dim rs As Recordset
    Dim NumberOfRecords As Long
    Set rs = CurrentDb.OpenRecordset("SELECT * FROM JOB")
    If Not rs.EOF Then
    rs.MoveLast
    NumberOfRecords = rs.RecordCount
    End If
    rs.Close
    Set rs = Nothing
    End Function

    but if you just need to know if any records came back, just check the recordsets EOF property

Posting Permissions

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