Solved

GetRows returns an array with ubound -1

Posted on 2002-06-06
3
767 Views
Last Modified: 2008-01-09
The recordset returned has only one record.  Stepping through the code shows the recordcount as 1 (correctly) when this is executed:
    rs.MoveLast
    ....

    If xErr = 3021 Then
        fExtractDataByStore = 0
    Else
        rs.MoveFirst
        vData = rs.GetRows(rs.RecordCount)
        fExtractDataByStore = rs.RecordCount
        Debug.Print LBound(vdata, 1), Ubound(vdata, 1)
        Debug.Print LBound(vdata, 2), Ubound(vdata, 2)
    End If

The debug output looks like this:
0 -1
0 7

The recordset has no problems, all the fields have data, but the GetRows is not returning useful information.

This is confusing me.
0
Comment
Question by:PaulHews
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
rpai earned 100 total points
ID: 7060119
Works fine for me.
I tried the following lines of code:-
Dim vData As Variant
vData = rs.GetRows(1)
Debug.Print LBound(vData, 1), UBound(vData, 1)
Debug.Print LBound(vData, 2), UBound(vData, 2)

The debug output looks like this:-
 0             8 (My recordset has 8 fields)
 0             0
0
 
LVL 38

Author Comment

by:PaulHews
ID: 7060131
I also tried hardcoding the NumRows parameter and tried compacting the database incase recordcount was doing something funny.  Still the weird ubound.
0
 
LVL 38

Author Comment

by:PaulHews
ID: 7060165
Just found the problem.  Had an expression in one of the selected fields that evaluated to a division by zero on this particular run.  It didn't cough up any errors other than the messed up GetRows (although trying to inspect that particular field did give me a "duplicate definition" error, weird, huh?)  Solved it using an IIF function in the expression.  Thanks for trying to help here, I appreciate it.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now