如何访问记录集中的值
以这段代码为例:
sSQL = "select CtyMarket from Market where Country = '" & Country.Value & "'"
Set rec = CurrentDb.OpenRecordset(sSQL)
该语句可以返回多个值。我如何访问这些值?
Take for example this code:
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,为了获取所有值,您可以浏览记录集中的字段和记录。它可能看起来像这样:
获取数据的其他方法是使用记录集对象的 getrows 和/或 getstring 方法,但我不记得这些方法是否可用于 DAO 记录集。您还可以为特定字段上的特定值设置过滤器等
well, in order to get all the values you could browse both fields and records in your recordset. It could look like that:
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
我使用此函数在读取记录集时不关心 NULL 值:
永远不要相信
rec.recordcount
的确切数量,但rec.RecordCount>0
是安全的。这就是为什么在使用记录集时绝不使用for循环。如果您想知道记录计数,您首先必须做的是rec.movelast
然后是rec.movefirst
我知道有两种不同的方法:
或
I use this function to not care about NULL values when reading recordsets:
Never trust the exact amount of
rec.recordcount
butrec.RecordCount>0
is safe. That's why you should never use a for loop when using a recordset. If you'd like to know the recordcount anyway what you have to do first isrec.movelast
and thenrec.movefirst
There are two different ways that I know of:
or