MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Trap on Null? Combo Box?

Posted by J on February 15, 2002 11:16 PM

I have a routine that is set up to modify a selection that the user chooses by way of a combo box. I am confused because I can't seem to find a way to check to make sure that the user has actually selected a name to edit prior to pressing the "Edit" command button. I have tried to trap on the combo box = to "" = "null" = null = 0 and It doesn't seem to work here is the type of trap I set up.

If customerform.cust = "" Then
MsgBox "Please select a name to edit"
Exit Sub
End If

Where customerform.cust is the value of the combobox. I know there has to be a way to successfully compare it against something but I just can't seem to figure it out. Any help would be appreciated.


Posted by Juan Pablo G. on February 16, 2002 6:04 AM

Try the .ListIndex property, like this

If ComboBox1.ListIndex = -1 then
'No Selection
'Did select something
End If

Juan Pablo G.