Kamis, 12 April 2012

Re: [MS_AccessPros] Proc_Exit

 

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@msn.com>
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