Check the access form field for Null, if not Null, then call the add function

I have this simple access form, which when you fill out the form and forget to fill in the Business Unit field, msgBox will appear telling you about it, and setFocus for this Combo field itself. If it is not null, I want to call the following function. The first part of this code works, but when it is not Null, it will not continue.

 Private Sub Image_AddNon_RPS_Button_Click()

 If IsNull(Me.BU_Selected_Add) Then
    MsgBox "Please Select a Business Unit!", vbOKOnly
            Exit Sub
         End If
    Me.Combo_BU_Selector.SetFocus
    Exit Sub
If Not IsNull(Me.BU_Selected_Add) Then
    Call Add_RPS_LINE
        End If
End Sub

Does anyone see where I am completely in the left margin?

+3
source share
1 answer

You have an extra one Exit Sub(the one after the first MsgBox) that prevents your code from doing what you want. Also, your first one End Ifis in the wrong place.

- :

Private Sub Image_AddNon_RPS_Button_Click()

  If IsNull(Me.BU_Selected_Add) Then                     ' No business unit 
      MsgBox "Please Select a Business Unit!", vbOKOnly  ' Tell user 
      Me.Combo_BU_Selector.SetFocus                      ' Focus the control
      Exit Sub                                           ' Exit the method
  End If                                                 ' End the IsNull test

  Call Add_RPS_LINE      ' You only get here if the above doesn't execute
End Sub

, If End If , , (), .: -)

+6

All Articles