0

I'm making a form and need to make sure that the value the user inputs in the combo box is a member of the table where the combo box was sourced from. Currently, the user can select from the dropdown list, but if they decided to try and edit the value, they would be able to. I either need the code to check that the value they entered matches a value in the table, or I need to make it so that the user is unable to edit the combo box in the first place.

I've tried using this On Key Press event procedure to deny editing, but every time I try editing the combo box after that, I just get an error box thrown and then the edit stays.

Private Sub User_Name_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    KeyAscii = 0
End Sub

I would just like to add something to a button I have at the end of the form that checks if the value is in the member list, and if it is, continue with the other code, if it isn't, exit sub.

I would like to use something along the lines of this question: Checking if a value is a member of a list but I'm not sure how to dimension my table as an array.

ndemo
  • 1
  • 2

1 Answers1

1

setting the combobox property .LimitToList = True is the simplest solution, but check the help file to ensure this is adequate for your needs, as there are many ways to do this.