Kamis, 12 April 2012

Re: [MS_AccessPros] Proc_Exit

 

Thanks John and Crystal.

I appreciate your explanation Crystal. As to why--I realized that I may have a problem since I have a couple of places where I put the rst.close, Set rst = Nothing etc. under Proc_Exit believing that it would be used upon exiting and thus I didn't have to put it with every Exit Sub. So now I know that the rst's and db's in those instances are not being handled properly.

So if I have several Exit Subs before the end of the procedure and a db and rst have been opened previously, what do you recommend--including closing and setting to nothing before each Exit Sub?

Thanks!

--- In MS_Access_Professionals@yahoogroups.com, Crystal <strive4peace2008@...> wrote:
>
> Hi Connie,
>
> Proc_Exit:
>
> is a line label, not an executable statement.  The error handler is directed to go here after an error message is given since an error often means the procedure will not execute properly.  When code is directed to a line label, it is the next statement that gets executed.  think of the line label like an EXIT DOOR :)
>
> for reference for others, here is an example of what I assume you are doing:
>
>
> '~~~~~~~~~~~~~~~~~~~~~~~~
>    On Error GoTo Proc_Err
>
>    'statements
>  
> Proc_Exit:
>    Exit sub
>  
> Proc_Err:
>    MsgBox Err.Description, , _
>         "ERROR " & Err.Number _
>         & "   ProcedureName "
>
>    Resume Proc_Exit
>    Resume
>  
> '~~~~~~~~~~~~~~~~~~
>
> Warm Regards,
> Crystal
>
>  *
>    (: have an awesome day :)
>  *
>
>
>
>
>
> ________________________________
> From: John Viescas <JohnV@...>
> To: MS_Access_Professionals@yahoogroups.com
> Sent: Thursday, April 12, 2012 10:11 AM
> Subject: RE: [MS_AccessPros] Proc_Exit
>
> Connie-
>
> If you want the next executed statement to be the one after the Proc_Exit label,
> then do:
>
>   GoTo Proc_Exit
>
> But if all Proc_Exit does is fall into an Exit Sub, why do that?
>
> John Viescas, author
> Microsoft Office Access 2010 Inside Out
> Microsoft Office Access 2007 Inside Out
> Building Microsoft Access Applications
> Microsoft Office Access 2003 Inside Out
> SQL Queries for Mere Mortals
> http://www.viescas.com/
> (Paris, France)
>
> ----------------------------
>
> From: MS_Access_Professionals@yahoogroups.com
> [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of mrsgoudge
> Sent: Thursday, April 12, 2012 5:45 PM
> To: MS_Access_Professionals@yahoogroups.com
> Subject: Re: [MS_AccessPros] Proc_Exit
>
>  
> John,
>
> Would I put "Exit" in the code to send it to Proc_Exit?
>
> Thanks again!
> Connie
>
> --- In MS_Access_Professionals@yahoogroups.com, John Viescas <JohnV@> wrote:
> >
> > Connie-
> >
> > No. Exit Sub leaves the code without executing anything else.
> >
> > John Viescas, author
> > Microsoft Office Access 2010 Inside Out
> > Microsoft Office Access 2007 Inside Out
> > Building Microsoft Access Applications
> > Microsoft Office Access 2003 Inside Out
> > SQL Queries for Mere Mortals
> > http://www.viescas.com/
> > (Paris, France)
> >
> > -------------------------------------
> >
> > From: MS_Access_Professionals@yahoogroups.com
> > [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of mrsgoudge
> > Sent: Thursday, April 12, 2012 5:12 PM
> > To: MS_Access_Professionals@yahoogroups.com
> > Subject: [MS_AccessPros] Proc_Exit
> >
> >  
> > Good morning/afternoon all!
> >
> > I have the following near the end of each procedure:
> > Proc_Exit:
> > Exit Sub
> >
> > If an early exit is required does "Exit Sub" in the code before this then go
> > through the Proc_Exit?
> >
> > Thanks!
> > Connie
> >
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
> [Non-text portions of this message have been removed]
>

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar