Results 1 to 4 of 4
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    An easier way to count records in a recordset

    I tried to apply the Count function in place of the code below but without success. Suggested simpler code example would be welcome.
    Thanks,
    Bill




    Code:
    Public Function basecount() As Integer
    Dim rsBaseUse As DAO.Recordset
    Dim strSQL As String
    
    strSQL = "SELECT * FROM QBaseUse"
    Set rsBaseUse = DBEngine(0)(0).OpenRecordset(strSQL)
    
    rsBaseUse.MoveLast
    
    basecount = rsBaseUse.RecordCount
        
    rsBaseUse.Close
    Set rsBaseUse = Nothing
    End Function

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    1 line of code:
    =Dcount("*","query")

  3. #3
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Try this:

    Dim basecount As variant
    basecount = dcount("*", "QBaseUse")

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Thanks guys,
    Bill

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Recordset Count
    By DMT Dave in forum Access
    Replies: 1
    Last Post: 06-20-2019, 05:30 AM
  2. Replies: 2
    Last Post: 05-17-2018, 09:50 AM
  3. COUNT Group Count Records COUNT FUNCTION
    By PMCOFFEY in forum Access
    Replies: 9
    Last Post: 11-09-2012, 09:40 PM
  4. Replies: 5
    Last Post: 09-14-2012, 04:56 PM
  5. Replies: 8
    Last Post: 08-11-2010, 09:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums