none
Combo Box Limit to List does not prevent deleting the choice RRS feed

  • Question

  • I have a combo box on a form and have limit to list set to Yes...

    But I discovered a user can click in the field and delete the selected choice... in other words the combo box field is blank.

    Limit to List does prevent entering a new value like "xyz" 

    How can I prevent a user from deleting the selected choice?

    Thanks for any help.

    Saturday, July 11, 2015 3:16 PM

Answers

  • Hi,

    You could make the field a "required" field at the table level. Or, you can use code in the Combobox's BeforeUpdate event to cancel the change if the user leaves the combobox empty. For example:

    Private Sub ComboboxName_BeforeUpdate(Cancel As Integer)
    
      If Me.ComboboxName & "" = "" Then
    
        Cancel = True
        Me.ComboboxName.Undo
        MsgBox "Combobox cannot be empty.", vbInformation, "Required!"
    
      End If
    
    End Sub

    Hope that helps...

    • Marked as answer by L.HlModerator Tuesday, August 4, 2015 9:20 AM
    Saturday, July 11, 2015 3:58 PM

All replies

  • You can set the table/field it is bound to as required. 

    You can also set the validation rule of the control to "Is Not Null."

    Saturday, July 11, 2015 3:56 PM
  • Hi,

    You could make the field a "required" field at the table level. Or, you can use code in the Combobox's BeforeUpdate event to cancel the change if the user leaves the combobox empty. For example:

    Private Sub ComboboxName_BeforeUpdate(Cancel As Integer)
    
      If Me.ComboboxName & "" = "" Then
    
        Cancel = True
        Me.ComboboxName.Undo
        MsgBox "Combobox cannot be empty.", vbInformation, "Required!"
    
      End If
    
    End Sub

    Hope that helps...

    • Marked as answer by L.HlModerator Tuesday, August 4, 2015 9:20 AM
    Saturday, July 11, 2015 3:58 PM