Group:  Microsoft Access ยป microsoft.public.access.modulesdaovba
Thread: getrows only getting one row?

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

getrows only getting one row?
news[ at ]mail.adsl4less.com 31.08.2006 12:12:52
Can someone please tell me where I'm going wrong? I've used getrows
before without any problems, but today, it's just not playing ball (or
more likely I've just forgotten how to do this).


Dim rs As Recordset
Dim arr As Variant

Set rs = DBEngine(0)(0).OpenRecordset("SELECT fdPersonName from
tbPeople")
Debug.Print rs.RecordCount ' Returns 3 as expected
arr = rs.GetRows
Debug.Print UBound(arr, 2) + 1 ' Returns 1 instead of 3

A watch on arr shows an array with bounds of 0,0.

Re: getrows only getting one row?
<david[ at ]epsomdotcomdotau> 31.08.2006 22:39:55
RecordCount is not valid unless you have loaded the
entire recordset by using movelast, or unless you are
using a table-type recordset.

(david)

<news[ at ]mail.adsl4less.com> wrote in message
news:1157026372.913217.149500[ at ]74g2000cwt.googlegroups.com...
[Quoted Text]
> Can someone please tell me where I'm going wrong? I've used getrows
> before without any problems, but today, it's just not playing ball (or
> more likely I've just forgotten how to do this).
>
>
> Dim rs As Recordset
> Dim arr As Variant
>
> Set rs = DBEngine(0)(0).OpenRecordset("SELECT fdPersonName from
> tbPeople")
> Debug.Print rs.RecordCount ' Returns 3 as expected
> arr = rs.GetRows
> Debug.Print UBound(arr, 2) + 1 ' Returns 1 instead of 3
>
> A watch on arr shows an array with bounds of 0,0.
>


Re: getrows only getting one row?
"Dirk Goldgar" <dg[ at ]NOdataSPAMgnostics.com> 01.09.2006 03:19:19
<news[ at ]mail.adsl4less.com> wrote in message
news:1157026372.913217.149500[ at ]74g2000cwt.googlegroups.com
[Quoted Text]
> Can someone please tell me where I'm going wrong? I've used getrows
> before without any problems, but today, it's just not playing ball (or
> more likely I've just forgotten how to do this).
>
>
> Dim rs As Recordset
> Dim arr As Variant
>
> Set rs = DBEngine(0)(0).OpenRecordset("SELECT fdPersonName from
> tbPeople")
> Debug.Print rs.RecordCount ' Returns 3 as expected
> arr = rs.GetRows
> Debug.Print UBound(arr, 2) + 1 ' Returns 1 instead of 3
>
> A watch on arr shows an array with bounds of 0,0.

Don't you have to pass the number of rows you want to retrieve? Maybe
that argument is defaulting to 1. Try:

With rs
If Not .EOF Then
.MoveLast
.MoveFirst
End If
arr = .GetRows(.RecordCount)
End With

or something along those lines.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Re: getrows only getting one row?
news[ at ]mail.adsl4less.com 01.09.2006 20:32:40

david[ at ]epsomdotcomdotau wrote:
[Quoted Text]
> RecordCount is not valid unless you have loaded the
> entire recordset by using movelast, or unless you are
> using a table-type recordset.
>
> (david)
>

But... recordcount is the one that's working, it's getrows() that
isn't.

Re: getrows only getting one row?
<david[ at ]epsomdotcomdotau> 03.09.2006 03:20:50

<news[ at ]mail.adsl4less.com> wrote in message
news:1157142760.437599.216170[ at ]i42g2000cwa.googlegroups.com...
[Quoted Text]
>
> david[ at ]epsomdotcomdotau wrote:
> > RecordCount is not valid unless you have loaded the
> > entire recordset by using movelast, or unless you are
> > using a table-type recordset.
> >
> > (david)
> >
>
> But... recordcount is the one that's working, it's getrows() that
> isn't.
>

really? what makes you think that? all the evidence you
have posted is that your (invalid) RecordCount returns a
different value than your (invalid) GetRows.


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net