本文介绍了GetRows的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我在使用Access 2000从桌子上直接读到一个

数组时遇到了麻烦。


Dim db As Database

Dim rsTime作为记录集

Dim TimeArray As Variant


设置db = CurrentDb

设置rsTime = db.OpenRecordset(" Time Record")

''只有在存在记录时才加载数组

If(rsTime.RecordCount 0)然后

rsTime.MoveLast:rsTime.MoveFirst

''记录数= 10

TimeArray = rsTime.GetRows

结束如果

只显示加载第一条记录。我只看到第0行

vResult = TimeArray(0,0)产生良好的数据

vResult = TimeArray(0,1)给我一个下标超出范围 ;

错误


任何想法都会受到赞赏。

Hank Reed

解决方案



我认为您需要指定从记录集

返回的行数。请尝试以下方法:


Dim db作为数据库

Dim rsTime作为记录集

Dim TimeArray As Variant


设置db = CurrentDb

设置rsTime = db.OpenRecordset(" Time Record")

''仅在存在记录时加载数组

If(rsTime.RecordCount 0)然后

rsTime.MoveLast

''记录数= 10

TimeArray = rsTime .GetRows(rsTime.RecordCount)

结束如果


HTH,

布鲁斯





为什么你会这样做呢?记录集是一个数组。为什么不

只需使用记录集做你想做的事情?


-

David W. Fenton

usenet at dfenton dot com

Hello,
I''m having trouble reading from a table directly into an
array using Access 2000.

Dim db As Database
Dim rsTime As Recordset
Dim TimeArray As Variant

Set db = CurrentDb
Set rsTime = db.OpenRecordset("Time Record")
'' Only load array if records exist
If (rsTime.RecordCount 0) Then
rsTime.MoveLast: rsTime.MoveFirst
'' The record count = 10
TimeArray = rsTime.GetRows
End If
It only appears to load the first record. I see only row 0
vResult = TimeArray(0,0) results in good data
vResult = TimeArray(0,1) gives me a "Subscript out of Range"
error

Any ideas would be appreciated.
Hank Reed

解决方案

I think you need to specify the number of rows you want returned from
your recordset. Try the following:

Dim db As Database
Dim rsTime As Recordset
Dim TimeArray As Variant

Set db = CurrentDb
Set rsTime = db.OpenRecordset("Time Record")
'' Only load array if records exist
If (rsTime.RecordCount 0) Then
rsTime.MoveLast
'' The record count = 10
TimeArray = rsTime.GetRows(rsTime.RecordCount)
End If

HTH,
Bruce



Why would you bother doing that? A recordset is an array. Why not
just use the recordset to do what you want?

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/


这篇关于GetRows的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 10:02