I have the following code opening a form and then doing some stuff.
Sub lag_ny_a3()
Dim frm As ufNyA3
Set frm = New ufNyA3
frm.Show
If Not frm Is Nothing Then
MsgBox("Doing stuff")
Unload frm
End If
End Sub
Then I have the following code in my form
Private Sub cmdAvbryt_Click()
Unload Me
End Sub
However, even if the cmdAvbryt-button is clicked in the form, the first code-snippet enters the if-statement, as if the form is not unloaded. Why is this, and how can I prevent the code in the if-statement to be executed if the cmdAvbryt-button is pushed?