[AccessD] Checking for Records in Recordsets

David Emerson newsgrps at dalyn.co.nz
Sun Apr 13 20:13:41 CDT 2014


Listers,

 

I have some code that gets recordsets and applies them to the sources of a
number of combobox controls.

 

The code looks like this:

 

    Set rstTemp = basRunDataObject("dbo.spfrmFunderServiceCode " &
Nz(Me!cboFilter, 0), adCmdText)

    Set Me.Recordset = rstTemp

    

    Set rstTemp = rstTemp.NextRecordset

 

    If rstTemp.EOF <> True Then 'Record exists

        Set Me!cboSearch.Recordset = rstTemp

    Else

        Set Me!cboSearch.Recordset = Null

    End If

 

The stored Procedure has a number of select statements to get a number of
record sets.

 

When a recordset has no records then an error 424 (Object Required) appears
when the "If rstTemp.EOF <> True" line is processed.  This seems to be
telling me that if a recordset has no records then it doesn't even get
returned as an empty recordset.  However, when I have multiple recordsets I
can use the "Set rstTemp = rstTemp.NextRecordset"  line to move to the next
expected recordset and it is the correct one for the next control.

 

How can I check if there are any records in a returned recordset and clear
the control source?

 

Regards

David Emerson
Dalyn Software Ltd
Wellington, New Zealand

 

 



More information about the AccessD mailing list