如何访问记录集中的值 [英] How to access values in a recordset

查看:49
本文介绍了如何访问记录集中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下面的代码为例:

sSQL = "select CtyMarket from Market where Country = '" & Country.Value & "'"
Set rec = CurrentDb.OpenRecordset(sSQL)

此语句可以返回多个值.如何获取这些值?

This statement can return more than one value. How can I access those values?

推荐答案

好吧,为了获取所有值,您可以浏览记录集中的字段和记录.看起来可能像这样:

well, in order to get all the values you could browse both fields and records in your recordset. It could look like that:

'You'll need to declare a new variable
Dim i as long

If rec.EOF and rec.BOF then
Else
    do while not rec.EOF
        for i = 0 to rec.fields.count - 1
            debug.print rec.fields(i).value
        next i
        rec.movenext
    loop
endif

获取数据的其他方法是使用记录集对象的getrows和/或getstring方法,但是我不记得DAO记录集是否可以使用这些方法.您还可以为特定字段上的特定值设置过滤器,等等

Other ways to get your data would be to use the getrows and\or getstring metyhods of the recordset object, but I do not remember if these are available with DAO recordsets. You could also set a filter for a specific value on a specific field, etc

这篇关于如何访问记录集中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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