I have a form with a combo box and a button, which when clicked, opens a report based on the option selected in the combo box. For this, in the event procedure of the button click, how do I code it so that if no option is selected in the combo box and the button is clicked, it should display a 'message' as a pop up. I know I should use the MsgBox option but I seem to be going wrong with the If loops. I doubt I am positioning the MsgBox command in the wrong place in the code below, as it does not pop up the msg box as I desire. What do I need to do to get over this?
Heres the code:
Private Sub btnMarket_Click()
If Me.Combo0 <> "" And Not IsNull(Me.Combo0) Then
Dim s As String
s = "1=1"
If Me.Combo0 <> "ALL" Then
s = "Market = '" & Combo0 & "'"
End If
DoCmd.OpenReport "repNewIntakeMarket", acViewPreview, , s
Else
MsgBox "Please select an option from the list of markets. Select All to view all markets.", vbOKOnly, "Market Required"
End If
End Sub
Appreciate your time and thoughts.