Unbound Combobox

M

Martin

I have an unbound combobox control that uses a table as the RowSource, it is
bound to Column 1. I have the Limit To List property set to Yes, but the
user can still bypass the data entry into this box leaving it empty/null.

I have tried using the NotInList event, but that does not prevent leaving
the control empty. Access Help for a Bound combobox suggests using the
Required property of the field, but since my control is unbound, there does
not appear to be a Required property.

Basically, I want to make sure an entry is made and that it matches one of
the values in the pulldown.

Does anyone have any suggestions on how to accomplish this?

Thanks.
 
F

fredg

I have an unbound combobox control that uses a table as the RowSource, it is
bound to Column 1. I have the Limit To List property set to Yes, but the
user can still bypass the data entry into this box leaving it empty/null.

I have tried using the NotInList event, but that does not prevent leaving
the control empty. Access Help for a Bound combobox suggests using the
Required property of the field, but since my control is unbound, there does
not appear to be a Required property.

Basically, I want to make sure an entry is made and that it matches one of
the values in the pulldown.

Does anyone have any suggestions on how to accomplish this?

Thanks.

Use the Combo NotInList event to require an in-list value selection.

Then to not allow a blank (Null) value, code the Form's BeforeUpdate
event to display a message, cancel the record update, and set focus to
the combo box.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.ComboName) Then
MsgBox "You cannot leave this Combo Box blank."
Cancel = True
Me.ComboName.SetFocus
End If

End Sub
 
M

Martin

The form's Before Update event would not work for me, so I wound up using
the control's On Exit event to check for the null.

Thanks for the suggestion.
 

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