Exit Sub Doesn't Happen

  • Thread starter Thread starter MAB
  • Start date Start date
M

MAB

In the following code, when the variable MarkUpValue is equal to -1, I want
to close the form and exit the sub routine for the cmdConfirm_Click() event.
However, it just seems to conveniently forget to exit the sub, and continues
to execute the code below the End If statement. Of course, the code down
there requires that the form be open (but it was closed because MarkUpValue
= -1). This results in a error, since the code below requires that the form
be open to function. I can't figure out why the form closes when the
variable = -1, but the execution of the code continues. Any ideas?


Private Sub cmdConfirm_Click()

If MarkUpValue = -1 Then
DoCmd.Close
Exit Sub
End If

....other code down here...

End Sub
 
MAB said:
In the following code, when the variable MarkUpValue is equal to -1,
I want to close the form and exit the sub routine for the
cmdConfirm_Click() event. However, it just seems to conveniently
forget to exit the sub, and continues to execute the code below the
End If statement. Of course, the code down there requires that the
form be open (but it was closed because MarkUpValue = -1). This
results in a error, since the code below requires that the form be
open to function. I can't figure out why the form closes when the
variable = -1, but the execution of the code continues. Any ideas?


Private Sub cmdConfirm_Click()

If MarkUpValue = -1 Then
DoCmd.Close
Exit Sub
End If

...other code down here...

End Sub

I don't think it should, and a quick test form I created doesn't do
that for me. Have you stepped through the code to see what happens line
by line? What is MarkUpValue and where is it defined?
 
Back
Top