Question : Combo box alert code not working

So, I have a combo box on a form. I want to verify that the user has selected something so I use the following code below.


It doesn't work the way it is. If I uncomment the Msgbox, comment the DoCmd and run it, everything works fine. I can then go in and comment the Msgbox back, and uncomment the rest and it works - until I close the database and reopen it.  What is causing that to happen? Is there a better way to verify a combo box has a value? Thanks for any help.
1:
2:
3:
4:
5:
6:
If Me.cboReason = "" Then
'        MsgBox "Nothing selected"
        DoCmd.Beep
        DoCmd.OpenForm "noDefect", acNormal, , , , acWindowNormal, False
        
    Else

Answer : Combo box alert code not working

try this

If Len(Me.cboReason & "")=0  Then
        MsgBox "Nothing selected"
        DoCmd.Beep
        DoCmd.OpenForm "noDefect", acNormal, , , , acWindowNormal, False
       
    Else
Random Solutions  
 
programming4us programming4us