Results 1 to 2 of 2
  1. #1
    Join Date
    May 2003

    Unanswered: Return RecordCount After Search

    I want to check the record count of a returned by a Query, with VBA, so that. I can set up a structure basically like this

    If SuccessfulSearch = False,
    then DoCMD.OpenQuery("LikeQuery")

    Basically using the first 3 charators of the searched for part number and running a like query. My problem is, its a fairly big database, on a fairly slow computer. So finally my Question.

    How can I get VBA to wait for the Query to finish, before checking the RecordCount property.

    thanks much BB.
    K did you Flashy thing me, K??

  2. #2
    Join Date
    Dec 2002
    Préverenges, Switzerland
    you have a couple of choices which involve trawling through your (big, slow) database twice: DCOUNT domain aggregate function and COUNT in SQL.

    other solution is to take your query results into a recordset and do a .movelast:

    'DAO code
    dim dabs as dao.database
    dim rex as dao.recordset
    dim accurateRecordCount as long
    set dabs = currentdb
    set recs = dabs.openrecordset(nameOfYourQuery)
    rex.movefirst 'not strictly necessary, just one of my bad habits.
    rex.movelast 'this fully populates the recordset
    accurateRecordCount  = rex.recordcount

Posting Permissions

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