Solved

GetRows returns an array with ubound -1

Posted on 2002-06-06
3
774 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

710 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