How do I test if a recordSet is empty? isNull?

前端 未结 5 451
暗喜
暗喜 2020-12-29 03:14

How can you test if a record set is empty?

        Dim temp_rst1 As Recordset
        Dim temp_rst2 As Recordset

        Set temp_rst1 = db.OpenRecordset(\"         


        
相关标签:
5条回答
  • 2020-12-29 03:55

    I would check the "End of File" flag:

    If temp_rst1.EOF Or temp_rst2.EOF Then MsgBox "null"
    
    0 讨论(0)
  • 2020-12-29 03:57

    If Not temp_rst1 Is Nothing Then ...

    0 讨论(0)
  • 2020-12-29 03:59

    A simple way is to write it:

    Dim rs As Object
    Set rs = Me.Recordset.Clone
    If Me.Recordset.RecordCount = 0 then 'checks for number of records
       msgbox "There is no records" 
    End if
    
    0 讨论(0)
  • 2020-12-29 04:05

    If temp_rst1.BOF and temp_rst1.EOF then the recordset is empty. This will always be true for an empty recordset, linked or local.

    0 讨论(0)
  • 2020-12-29 04:06

    RecordCount is what you want to use.

    If Not temp_rst1.RecordCount > 0 ...
    
    0 讨论(0)
提交回复
热议问题