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]