Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / May 2006

Tip: Looking for answers? Try searching our database.

Jumping

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
apollo8359 - 13 May 2006 00:46 GMT
Is there a way to jump to the end of a procedure? In the middle of my
procedure, if a field is null, I want a message box to alert the user, then
jump to the end, and not execute the remaining lines of code. I realize I
could wrap everything up in the various IF statements, but there are over
five of them and I don't like to nest that deep. And while I am asking these
questions, is there anywhere I can lookup all code verbiage so I don't have
to bother you wonderful people with such mundane questions. Thanks again.
Michael
Gene - 13 May 2006 02:31 GMT
Use a GOTO statement

example  GOTO EndOFPROC

ENDOFPROC:

> Is there a way to jump to the end of a procedure? In the middle of my
> procedure, if a field is null, I want a message box to alert the user, then
[quoted text clipped - 4 lines]
> to bother you wonderful people with such mundane questions. Thanks again.
> Michael
Gene - 13 May 2006 02:36 GMT
Actually a better alternative is an Exit Sub

> Is there a way to jump to the end of a procedure? In the middle of my
> procedure, if a field is null, I want a message box to alert the user, then
[quoted text clipped - 4 lines]
> to bother you wonderful people with such mundane questions. Thanks again.
> Michael
Marshall Barton - 13 May 2006 05:54 GMT
>Is there a way to jump to the end of a procedure? In the middle of my
>procedure, if a field is null, I want a message box to alert the user, then
[quoted text clipped - 3 lines]
>questions, is there anywhere I can lookup all code verbiage so I don't have
>to bother you wonderful people with such mundane questions. Thanks again.

I tend toward Exit Sub in spite of the general guidline of a
single exit point.

Alternatives to avoid the nesting issue are to use ElseIf or
Select Case.

If condition1 Then
    ...
ElseIf condition2 Then
    ...
Else
    ...
...
End If

Select Case True
Case condition1
    ...
Case condition2
    ...
...
Case Else
    ...
End Select

Signature

Marsh
MVP [MS Access]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.