如何将数据从访问表复制到VBA中的阵列? [英] How Can I Copy Data From an Access Table to An array In VBA?

查看:94
本文介绍了如何将数据从访问表复制到VBA中的阵列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个程序,该程序可以从表的一个字段中获取数据,并将整个列放入数组中,甚至只是从表本身读取数据。该代码似乎使用了某种形式或其他我想使用的数组。

I'm working on a program that can take data from one field in a table and put that whole column into an array or even just read from the table itself. The code seems to use a form or something else I would like to use an array.

推荐答案

这将起作用:

Dim rstData    As DAO.Recordset
Dim v          As Variant

Set rstData = CurrentDb.OpenRecordset("select FirstName from FaxBook3")
v = rstData.GetRows(rstData.RecordCount)

v现在将是所有名字的数组。如果您的查询具有多个列,则该数组将/可以是多维的。

"v" will now be a array of all first names. The array will/can be multi-dimensional if your query has multiple columns.

这篇关于如何将数据从访问表复制到VBA中的阵列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆