checking a combo box for data

G

Guest

I have a combo box on a form that I would like to check to see if a user has
selected something. If not, a message box will pop up and tell the user to
select an item from the combo box. I have code something like this in a
command button on the form.

If Forms![frmRBName]![cboName] = "" Then
MsgBox "You must select your name before proceeding"

The message box is never activated when the command button is clicked - i.e.
when the combo box is empty. This has to be a simple fix. What am I missing?

Nick
 
M

Marshall Barton

ndunwoodie said:
I have a combo box on a form that I would like to check to see if a user has
selected something. If not, a message box will pop up and tell the user to
select an item from the combo box. I have code something like this in a
command button on the form.

If Forms![frmRBName]![cboName] = "" Then
MsgBox "You must select your name before proceeding"

The message box is never activated when the command button is clicked - i.e.
when the combo box is empty.


Most likely, the combo box has a Null value instead of a
zero length string (ZLS).

Thry using this instead:

If IsNull(Me.[cboName]) Then
MsgBox . . .
 

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

Top