Reputation: 15
I am able to open the Form with the code below
**Private Sub EDit_Click()
DoCmd.OpenForm "State", acNormal, "", "[S_ID]=" & [RM_State], , acNormal
End Sub**
What I want is to add a Popup Error Message saying "Select the State from the List." when the combobox value is null (nothing is selected)
I have tried below code but it seems code is not right
**Private Sub EDit_Click()
DoCmd.OpenForm "State", acNormal, "", "[S_ID]=" & [RM_State], , acNormal
If (RM_State = 0) Then
MsgBox ("Select the State from the List.") Return
End If End Sub**
I am getting Error Run-Time Error'3075' -
Upvotes: 0
Views: 31
Reputation: 621
I would use IsNull() function for checking RM_State..
Private Sub EDit_Click()
If IsNull(RM_State) Then
MsgBox "Select the State from the List."
Exit Sub
End If
DoCmd.OpenForm "State", acNormal, "", "[S_ID]=" & RM_State, , acNormal
End Sub
Upvotes: 0