Combo Box Null

D

djf

I want the user to get an error message if they do not choose a value in a
combo box. Here's my code, cmbSubGrp is the name of my combo box. What am
doing wrong?

Dim Itm As Variant

If cmbSubGrp.Value = Null Then
Itm = MsgBox("You must select a" & _
" Receiving Group!", 0, "No Selection Made")
Exit Sub
End If
 
D

Dirk Goldgar

djf said:
I want the user to get an error message if they do not choose a value in a
combo box. Here's my code, cmbSubGrp is the name of my combo box. What am
doing wrong?

Dim Itm As Variant

If cmbSubGrp.Value = Null Then
Itm = MsgBox("You must select a" & _
" Receiving Group!", 0, "No Selection Made")
Exit Sub
End If


By definition, nothing is ever equal to Null (because Null represents
"unknown" or "unavailabe" or "not applicable"). Not even Null is equal to
Null.

To solve your problem, use the IsNull function:

If IsNull(cmbSubGrp) Then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top