Re: is Nothing vs = Empty

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Sep 30, 8:26 pm, "Laurel" <FakeM...@xxxxxxxxxxx> wrote:
I want to put code in my routines to be sure that a recordset is never left
unclosed, to prevent memory leaks, as I've been advised.

If Not (irst_ClassPeriods Is Nothing) Then
irst_ClassPeriods.Close
Set irst_ClassPeriods = Nothing
End If

What about if the recordset is not Nothing but isn't open? The
paranoid coder pattern I see is more like this:

On Error Resume Next
irst_ClassPeriods.Close
DoEvents
Set irst_ClassPeriods = Nothing
DoEvents
On Error Goto Err_Handler
blnSuccess = irst_ClassPeriods Is Nothing

IMO you should know when a recordset is open/Nothing so a paranoid
catch-all routine should be unnecessary.

Jamie.

--


.



Relevant Pages

  • Re: Get report to print data from ADO recordset created at runtime
    ... I plan to create a recordset, ... to a report and use SendTo to email the report as an .rtf file. ... Global gOldValue As Variant ... On Error GoTo cboFindObject_AfterUpdate_Err ...
    (microsoft.public.access.modulesdaovba)
  • Re: Get report to print data from ADO recordset created at runtime
    ... I would make this via local table - just insert all changes into table (instead of recordset), then build a report, bound to this table, and after send - clear it. ... Global gOldValue As Variant ... On Error GoTo cboFindObject_AfterUpdate_Err ...
    (microsoft.public.access.modulesdaovba)
  • Re: subform line number
    ... work for me in an ADP environment. ... DAO recordsets, but, in ADPs, the order of records in a form's ADO recordset ... On Error GoTo ErrThis ... > Just add an Unbound control to display a RecordNumber. ...
    (microsoft.public.access.formscoding)
  • Question about querytable vs copyfromrecordset
    ... way to copying the contents of a recordset into a spreadsheet. ... Public Sub createQueryTable(ByRef sht As Worksheet, ... cn.Execute "drop view qryTMRC" ... On Error GoTo 0 ...
    (microsoft.public.excel.programming)
  • Re: Return Value and Output Variable Always Zero
    ... To get values from the output parameters you first need to proceed with the ... Basically that means you need to close recordset first and then ... On Error GoTo OpenAcctError ...
    (microsoft.public.vb.database.ado)