Results 1 to 2 of 2
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919

    Unexpected results with DAO recordset

    The following code is a partial implementation of a function that creates a recordset based on a query. When the query runs independently, there are 127 records found. Yet, when I run the code in debug mode and check the value of "iRow" at the "jCol = " statement , its value is one (1). iRow and iCol are global to the module. What am I missing?



    Function LoadGroup_ALL()
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* =*=*=*=*=*=*=*=*=*=*
    ' Load up the rsGrpALL recordset, allocate and load the names and numbers in the BCarray. *
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* =*=*=*=*=*=*=*=*=*=*
    Dim rsGrpALL As DAO.Recordset
    Dim iWork As Integer
    Dim jWork As Integer

    Set rsGrpALL = DBEngine(0)(0).OpenRecordset("QBroadcastGroupALL")
    iRow = rsGrpALL.RecordCount
    jCol = iGroups + 5

    ReDim strBCarray(iRow, jCol)

    iWork = 1
    jWork = 1


    rsGrpALL.Close
    Set rsGrpALL = Nothing
    End Function

  2. #2
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    To get the correct value of the recordcount, you have to move to the last record of the recordset and then check the recordcount:

    rsGrpALL.movelast
    iRow = rsGrpALL.RecordCount
    rsGrpALL.movefirst

    The recordcount property is intialized to 1 when the recordset is opened.

    If all you want is the number of records in the query, you don't need a recordset - you can use DCount with no criteria:

    irow = DCount("*", "QBroadcastGroupALL")

    What is iGroups? It is also global to the module?

    John

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

Similar Threads

  1. Replies: 2
    Last Post: 03-08-2012, 12:59 PM
  2. Replies: 3
    Last Post: 12-26-2011, 10:45 AM
  3. Unexpected Results from Curdir?
    By bginhb in forum Programming
    Replies: 6
    Last Post: 08-17-2011, 03:58 PM
  4. InStrRev returning unexpected results
    By jgelpi16 in forum Programming
    Replies: 2
    Last Post: 12-07-2010, 01:04 PM
  5. Query showing unexpected results
    By johnmerlino in forum Queries
    Replies: 30
    Last Post: 10-25-2010, 07:08 AM

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