[AccessD] Checking for Records in Recordsets

Darryl Collins darryl at whittleconsulting.com.au
Sun Apr 13 22:42:32 CDT 2014


I had similar questions on the code logic / syntax, but I figured I was only seeing part of the deal and there might be good / other reasons for the choice of code.
But it did seem a bit odd prima facie.

Regards
Darryl.



-----Original Message-----
From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bill Benson
Sent: Monday, 14 April 2014 1:14 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Checking for Records in Recordsets

A question: why are you setting Me.recordset = rstTemp?

Personally I don't see how rstTemp.EOF I'd giving an error when the Set statement just prior to that does not.

I could see if the Set statement was failing how the assignment might not replace the prior existing definition of rstTemp, as happens when setting other objects equal to something undefined will do (I think).

Anyway, no help here, sorry, just questions!
On Apr 13, 2014 9:17 PM, "David Emerson" <newsgrps at dalyn.co.nz> wrote:

> 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
>
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list