Darryl Collins
darryl at whittleconsulting.com.au
Sun Apr 13 20:49:24 CDT 2014
Hi David, I use "IF rstTemp.recordcount > 0" rather than EOF when I do this sort of thing. I would normally test if recordcount > 0 = TRUE before trying to do anything with the control source. If you just care if it has 'something' in the RS than count will do. You need an accurate count you need to test something exists and then .movelast, .movefirst. In air code. Check if rs.recordcount > 0 If TRUE then do your thing with the form If FALSE try the next RS or something else. Hope that helps Cheers Darryl. -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of David Emerson Sent: Monday, 14 April 2014 11:14 AM To: AccessD Subject: [AccessD] Checking for Records in Recordsets 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 -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com