ms访问 – 访问VBA:如何测试recordSet是否为空?参考isNull?

如何测试记录集是否为空?

        Dim temp_rst1 As Recordset
        Dim temp_rst2 As Recordset

        Set temp_rst1 = db.OpenRecordset("SELECT * FROM ORDER_DATA WHERE SKUS_ORDERED = '" & curSKU1 & "' AND [ORDER] = " & curOrder)
        Set temp_rst2 = db.OpenRecordset("SELECT * FROM ORDER_DATA WHERE SKUS_ORDERED = '" & curSKU2 & "' AND [ORDER] = " & curOrder)

        If IsNull(temp_rst1) Or IsNull(temp_rst2) Then MsgBox "null"

我根据select语句打开了几个记录集。如果没有记录,IsNull会返回true吗?

我会检查“结束文件”标志:

If temp_rst1.EOF Or temp_rst2.EOF Then MsgBox "null"
http://stackoverflow.com/questions/6793097/access-vba-how-to-test-if-recordset-is-empty-isnull

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:ms访问 – 访问VBA:如何测试recordSet是否为空?参考isNull?