Selasa, 24 Februari 2015

Re: [MS_AccessPros] Proper way to exit procedure if RS is empty

 

Elizabeth-


It's always best to close and set to Nothing any DAO objects - except a Database object that is set to the current database.

Example:

Dim db As DAO.Database, rst As DAO.Recordset

    Set db = CurrentDb
    Set rst = db.OpenRecordset("SELECT * FROM SomeTable")
    If rst.EOF Then GoTo Cleanup
    ' process the recordset


Cleanup:

    rst.Close
    Set rst = Nothing
    Set db = Nothing



John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
SQL Queries for Mere Mortals 
(Paris, France)




On Feb 24, 2015, at 3:45 PM, glcass58@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

Hi all-

What is the proper way to exit a procedure if the record set is empty?  Exit Sub or Goto Proc_exit?  If a record set is empty do you need to close it and Set RS = nothing?

Thanks as always for your guidance!

Elizabeth


__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

.

__,_._,___

Tidak ada komentar:

Posting Komentar