Ali*_*Ali 6 ms-access recordset
以这段代码为例:
sSQL = "select CtyMarket from Market where Country = '" & Country.Value & "'"
Set rec = CurrentDb.OpenRecordset(sSQL)
Run Code Online (Sandbox Code Playgroud)
此语句可以返回多个值。我如何访问这些值?
好吧,为了获得所有值,您可以浏览记录集中的字段和记录。它看起来像这样:
'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
Run Code Online (Sandbox Code Playgroud)
获取数据的其他方法是使用记录集对象的 getrows 和\或 getstring 方法,但我不记得这些方法是否适用于 DAO 记录集。您还可以为特定字段上的特定值设置过滤器等